Hi,
Try:
x<- c("2/26/13 11:59 PM", "2/25/13 10:25 AM")
strptime(x,"%m/%d/%y %I:%M %p")
#[1] "2013-02-26 23:59:00" "2013-02-25 10:25:00"
#or
library(lubridate)
parse_date_time(x,"%m/%d/%y %I:%M %p")
# 2 parsed with %m/%d/%y %I:%M %p
#[1] "2013-02-26 23:59:00 UTC" "2013-02-25 10:25:00 UTC"
A.K.
>I'm a newbie to R but not programming. ?
>
>I've researched online and through this forum and am unsure of
why I'm not getting a as.date object to only store a limited amount of
data. ?The date >is in the format of: 2/26/13 11:59 PM in a .csv file
with over 5000 data points. ?My as.date function reads: >
>> gld <- read.csv("c:/data/gbpdata.csv", stringsAsFactors=F)
>> gld_dates <- as.Date(gld[,1], format="%m/%d/%y %H:%M %p")
>> gld_dates:
>
>[36775] "2013-04-03" "2013-04-03" "2013-04-03"
"2013-04-03" "2013-04-03" "2013-04-03"
"2013-04-03" "2013-04-03" "2013-04-03"
>
>What am I doing wrong? ?Thanks in advance for your replies.