> Sys.Date()
[1] "2009-11-08"
> as.Date("05/29/1971", format = "%m/%d/%Y")
[1] "1971-05-29"
> as.numeric((Sys.Date() - as.Date("05/29/1971", format = "%m/%d/
%Y")) / 365.25)
[1] 38.44764
or perhaps more clearly:
EndDate <- Sys.Date()
StartDate <- as.Date("05/29/1971", format = "%m/%d/%Y")
To clarify.
Lets turn a date into an age. Given 05/29/1971 in mm/dd/
format. What is the year difference between then and today?
This would be the "age" requested that starts 05/29/1971 as
one.
Thanks,
Jim
David Winsemius wrote:
>
> On Nov 8, 2009, at 3:11 PM, frenchcr wrote:
>
>>
>>
>> w
On Nov 8, 2009, at 3:11 PM, frenchcr wrote:
why do you use 365.25?
As opposed to what?
--
David
dates<-as.character(data[,"date_commissioned"]); # convert dates to
characters
#dates[1:10]
#[1] "19910101" "19860101" "19910101" "19860101" "19910101" "19910101"
"19910101" "19910101" "199
why do you use 365.25?
dates<-as.character(data[,"date_commissioned"]); # convert dates to
characters
#dates[1:10]
#[1] "19910101" "19860101" "19910101" "19860101" "19910101" "19910101"
"19910101" "19910101" "19910101" "19910101"
dateObs <- as.Date(dates,format="%Y%m%d")
#dateObs[1:10]
#[1] "1
it sure does thank you!
> will this work for you
>
> x <- c('19910101', '19950302', '20010502')
> today <- Sys.Date()
> x.date <- as.Date(x, format="%Y%m%d")
> round(as.vector(difftime(today , x.date, units='day') / 365.25))
[1] 19 15 9
>
On Sun, Nov 8, 2009 at 2:44 PM, wrote:
> Hi Jim,
>
As Jim has noted, if the dates you have below are an 'end date', you
need to define the time0 or start date for each to calculate the
intervals. On the other hand, are the dates you have below the start
dates and you need to calculate the time to today? In the latter case,
see ?Sys.Date to
What is the frame of reference to determine the age? Check out 'difftime'.
On Sun, Nov 8, 2009 at 1:50 PM, frenchcr wrote:
>
> Ive got a big column of dates (also some fields dont have a date so they have
> NA instead),
> that i have converted into date format as so...
>
>
> dates<-as.character
Ive got a big column of dates (also some fields dont have a date so they
have NA instead),
that i have converted into date format as so...
dates<-as.character(data[,"date_commissioned"]); # converted dates to
characters
dates[1:10]
[1] "19910101" "19860101" "19910101" "19860101" "19910101" "199
8 matches
Mail list logo