Hi all,

this one left me a bit puzzled, as I don't seem to find a function to
perform this easily. I must have overlooked the obvious, so sorry in
advance.

I have a list of dates in numerical format (i.e. 34576), defined as
the number of days that passed since january 1st 1900. So I apply the
function :

> MyDate <-as.Date(34576,origin="1900-01-01")
> MyDate
[1] "1994-09-01"

But then I want to do something like :
MyYear <- a.year.function(MyDate)

MyYear should have the numerical value 1994. Alas, I don't find any
function like that. I know I can take a substring of MyDate and
convert to numeric, or even use the function "seq()" :

> length ( seq ( as.Date("1900-01-01"), MyDate, "years" ) ) + 1900 - 1
[1] 1994

but that seems quite a way around. Can somebody tell me where the
appropriate function is hiding?
Thank you in advance.
Joris

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to