Skip to content

Extracting day of month from Date objects

3 messages · Phil Spector, Kang Min, David Winsemius

#
I've always found the chron library to be useful for
tasks like this:
[1] 7  25 26 25 10 24 1  31 12 8 
31 Levels: 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < ... < 31

Notice that it returns the days as factors.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
On May 24, 2011, at 10:19 AM, Kang Min wrote:

            
#
Thanks Phil, chron is good.
On May 25, 1:34?am, Phil Spector <spec... at stat.berkeley.edu> wrote:
#
On May 24, 2011, at 1:34 PM, Phil Spector wrote:

            
Could also use as.POSIXlt which is a base function. POSIXlt objects  
are internally a list of integers with a day of the month entry:

 > as.POSIXlt(y)$mday
  [1] 27 24 11 14 17  5  7 16  2 12

So take your pick:  character, factor or numeric values can be produced.