Skip to content
Prev 86935 / 398506 Next

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

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 your as.POSIXct calls as GMT does not
have daylight savings time.

See the Help Desk article in R News 4/1 for more on this.


On 2/21/06, gerald.herbert at hubbardbreeders.com
<gerald.herbert at hubbardbreeders.com> wrote:
Message-ID: <971536df0602210808r333a89f0g1e27e99a30b8ce7e@mail.gmail.com>
In-Reply-To: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAUmL1BciWlkSJzbtE4pRe0sKAAAAQAAAA7YffOmYFSU645jkej1wJmwEAAAAA@hubbardbreeders.com>