Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Help with incrementing a DateTime field
Mon, Dec 8 2008 6:12 PMPermanent Link

Norman Rorke
I'm trying to increment a DateTime field by given number of days.

I tried using the sql statement "UPDATE XTABLE SET MY_DATE=MYDATE + 7"
but this has no effect at all.

Help please !!

Norman
Desktop Financials Ltd
Mon, Dec 8 2008 6:37 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Norman,

> I'm trying to increment a DateTime field by given number of days.
>
> I tried using the sql statement "UPDATE XTABLE SET MY_DATE=MYDATE + 7"
> but this has no effect at all.

That's because TIMESTAMP field values are internally stored as
cumulative milliseconds, so what you are in fact doing is adding 7
milliseconds to MYDATE, not 7 days.
So, to add 7 days to MYDATE you must actually add
604800000 = 7*24*60*60*1000 = number of milliseconds in 7 days :

  UPDATE XTABLE SET MY_DATE=MYDATE + 604800000

--
Fernando Dias
[Team Elevate]
Mon, Dec 8 2008 6:46 PMPermanent Link

Norman Rorke
Fernando,

Thanks for the quick response

Norman

Image