[R] Week number from a date

Patrick Breheny patrick.breheny at uky.edu
Wed Feb 22 14:55:48 CET 2012


To give a little more detail, you can convert your character strings 
into POSIX objects, then extract from it virtually anything you would 
want using strftime.  In particular, %W is how you get the week number:

 > dateRange <- c("2008-10-01","2008-12-01")
 > x <- as.POSIXlt(dateRange)
 > strftime(x,format="%W")
[1] "39" "48"

--Patrick

On 02/22/2012 08:37 AM, Ingmar Visser wrote:
> ?strptime is a good place to start
> hth, Ingmar
>
> On Wed, Feb 22, 2012 at 2:09 PM, arunkumar1111<akpbond007 at gmail.com>  wrote:
>
>> Hi
>>
>> My data looks like this
>>
>> startDate="2008-06-01"
>>
>> dateRange =c( "2008-10-01","2008-12-01")
>> Is there any method to find the week number from the startDate range



More information about the R-help mailing list