[R] Convert Numeric (20090101) to Date

jim holtman jholtman at gmail.com
Wed Mar 7 02:40:23 CET 2012


try this:

> x <- as.POSIXct("20090101", format = "%Y%m%d")
> x
[1] "2009-01-01 EST"
>


On Tue, Mar 6, 2012 at 7:38 PM, RHelpPlease <rrumple at trghcsolutions.com> wrote:
> Hi there,
> Does it exist where R can convert a numeric date (20090101) to a "proper"
> date format?  (Ideally dd-mm-yyyy)
>
> Original data (in this case) is in .DAT format.  I read the multi-column
> data with the read.fwf function, where I specified the column width for the
> eight digit date (example above).  After the .DAT data is read-in &
> formatted in R, it is to be exported to Excel.
>
> I understand that with the as.Date function, 20090101 is understood as the
> number of days from the R origin date.
>
> I read that SAS has the capability to convert 20090101 to a date, so I'm
> hoping R does as well.  Conversion to a date in Excel does not work.
>
> Help in this matter is most appreciated!
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Convert-Numeric-20090101-to-Date-tp4451859p4451859.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list