Transforming a long date string to a Date in R
r
Solution
If you just want the date, then just specify that portion in the `format` argument:
as.Date("25-APR-2013 03.05.03.000000000 PM","%d-%b-%Y")
#[1] "2013-04-25"
If you wanted the full date-time, use `as.POSIXct` with a custom `format`:
as.POSIXct("25-APR-2013 03.05.03.000000000 PM",format="%d-%b-%Y %I.%M.%OS %p")
#[1] "2013-04-25 15:05:03 CDT"
Problem
I have a date variable that is formatted as: ``` 25-APR-2013 03.05.03.000000000 PM ``` I have converted it to a character and tried to get it to format. I did use the help documentation for as.Date but it did not help me. I am trying to find a solution to get this into a Date type of the standard %Y-%m-%d ``` > df$DELETE_DATE [1] "01-JUN-2011 05.24.12.000000000 AM" [2]"01-SEP-2011 03.54.01.000000000 AM" [3]"01-SEP-2012 05.20.10.000000000 AM" [4] "01-JAN-2013 02.45.55.000000000 AM" ``` This is 4 out of 3.6 million. I am open to any suggestions. Thanks