Link to home
Start Free TrialLog in
Avatar of kenuk110
kenuk110

asked on

How to minus 6 hours from a timestamp?

Hi,

I have a need to minus 6 hours from a time stamp if the current timestamp is greater than the current time.

I have attached the script for you to see.

Not sure what I'm doing wrong here.

Any help would be much appreciated.

Regards

Ken
UPDATE SMSIN_copy
SET validDate = realdate - 6 hour
where realdate > CURRENT_TIMESTAMP()

Open in new window

Avatar of miqrogroove
miqrogroove
Flag of United States of America image

Timestamps are expressed in seconds, so,

UPDATE SMSIN_copy
SET validDate = realdate - (6 * 60 * 60)
where realdate > CURRENT_TIMESTAMP()
ASKER CERTIFIED SOLUTION
Avatar of HuyBD
HuyBD
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kenuk110
kenuk110

ASKER

Thanks for the quick response!

I ran the script but I get an odd output, below is just one of the results

realdate = 2008-10-21 12:30:43

but

validDate = 2008-10-21 10:14:43

Any ideas??

Thanks
Brilliant, works perfectly. Cheers.