Database datetime

Hi,

I have a stupid issue with a database date type field. It should be done in 10 seconds. I’m stuck with it for an hour and can’t understand why it’s not working.

fields in my table:

expire_date DATETIME
warning_days INTEGER

I’m calling this to change the date back with warning_days and I get a number in response.

expire_date.setDate(-warning_days)
``` will evaluate in ```
1296302294550

, which probably is the number of miliseconds. But even if I use this one to create a new Date object the date will be 20 days before, not 2 as my warning_days is.

If I try to create a new Date object:

var date = new Date(expire_date.getFullYear(), expire_date.getMonth(), expire_date.getDate(), expire_date.getHours(), expire_date.getMinutes(), expire_date.getSeconds());

and call on this one date.setDate(-warning_days), I get in response ```
date: Sat Feb 26 2011 13:58:14 GMT+0200 (EET)


BUT, my ```
warning_days = 2
``` so from today 15 of March - 2 days should be 13 of March.

I'm really really confused. <img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /> 

I just one to see the date before x days starting from a date field in a table.

Please help!!!
var vDate = expire_date.setDate(expire_date.getDate() - warning_days);

I have recorded it! 5 seconds! ;-)

Yap, this makes sense. :idea: I think now it works.

Thanks :)

be aware, that it takes the time portion in respect also.

if you dont want that, you have to do this:

vDate = utils.timestampToDate(expire_date.setDate(expire_date.getDate() - warning_days));