[R] strftime - Dates from Excel files

John Kane jrkrideau at inbox.com
Sat Feb 4 21:54:05 CET 2012


I think you are using the wrong function. See ?strftime

Try
dataset=c("1/2/1978")
strptime(dataset,"%d/%m/%Y")

John Kane
Kingston ON Canada


> -----Original Message-----
> From: rrasterr at gmail.com
> Sent: Fri, 3 Feb 2012 14:34:09 +0100
> To: r-help at r-project.org
> Subject: [R] strftime - Dates from Excel files
> 
> Hi
> 
> I have many excel files were the Date field was not declared as date,
> so the dates look like this: 1/2/1978
> I know that the format is day/month/year
> 
> How can I make R change this to Date format?
> 
> If I use strftime, I get wrong dates:
> 
> dataset=c("1/2/1978")
> 
> strftime(dataset,"%d/%m/%Y")
> "19/02/0001"
> 
> 
> Thanks in advance.
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
Send any screenshot to your friends in seconds...
Works in all emails, instant messengers, blogs, forums and social networks.
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE



More information about the R-help mailing list