0

I am converting my string date to date formatted as dd-mm-yy using the as.Date function but this only work for double digit days, while returning NA for single digit day. Would somebody have any ideas why is this? Thanks example:

a<-"9112015"
a.converted<-as.Date.character(a,"%d%m%Y") 

-->returns NA

a<-"19112015"
a.converted<-as.Date.character(a,"%d%m%Y") 

---> works just fine

Phuong Ho
  • 67
  • 1
  • 6
  • 3
    `a[nchar(a) == 7] <- paste0('0', a[nchar(a) == 7])`, though that assumes the missing digit is from the day, not the month. Adding some delimiting characters would be helpful. – alistaire Dec 11 '17 at 00:07
  • Great, that works perfectly. Thanks – Phuong Ho Dec 11 '17 at 00:10

0 Answers0