"Ghosh, Sandeep" <[EMAIL PROTECTED]> writes:

> For the r script below 
> 
> >datestr <- "01/01/2004"
> >as.POSIXct(as.Date(datestr, "%d/%m/%Y"))
> I get the following output
>  "2003-12-31 18:00:00 Central Standard Time"
> 
> Why is the date a day before. I guess its something to do with the
> time, but is there a way to get it to return 2004-01-01 instead?

Just move to Denmark:

> datestr <- "01/01/2004"
> as.POSIXct(as.Date(datestr, "%d/%m/%Y"))
[1] "2004-01-01 01:00:00 CET"

The convention is that Date objects are pegged to 0:00 GMT (not sure
what the rationale is -- ISOdate uses 12:00 GMT -- but Brian probably
thought about it). An easy workaround is to add 12 hours...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])             FAX: (+45) 35327907

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to