[R] Number of Days Between Dates: Incorrect Results For Date Calucations.

2006-02-21 Thread gerald.herbert
In some cases, incorrect results are produced by the code below intended to calculate the number of days between 2 dates. The year in question was a leap year. Note the results for 2004-04-04 and 2004-04-05 are the same! They should be 37 and 38 respectively. as.integer(as.POSIXct(2004-04-02)

Re: [R] Number of Days Between Dates: Incorrect Results For Date Calucations.

2006-02-21 Thread Gabor Grothendieck
The results are actually correct if you consider daylight savings time. For example, try this and note that the difference is 23 hours, not 24 hours: as.POSIXct(2004-04-05) - as.POSIXct(2004-04-04) You can address this by either using Date or chron classes or adding the tz = GMT argument on

Re: [R] Number of Days Between Dates: Incorrect Results For Date Calucations.

2006-02-21 Thread Peter Dalgaard
[EMAIL PROTECTED] writes: In some cases, incorrect results are produced by the code below intended to calculate the number of days between 2 dates. The year in question was a leap year. Note the results for 2004-04-04 and 2004-04-05 are the same! They should be 37 and 38 respectively.