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 fo
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"
Just extract the portion of the string containing the useful info with substr() and feed it to as.Date()
orig.string<-"25-APR-2013 03.05.03.000000000 PM"
as.Date(substr(orig.string, start=1, stop=11), format="%d-%b-%Y")