Solved

How to minus 6 hours from a timestamp?

Posted on 2008-10-20
4
1,324 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:kenuk110
  • 2
4 Comments
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22764864
Timestamps are expressed in seconds, so,

UPDATE SMSIN_copy
SET validDate = realdate - (6 * 60 * 60)
where realdate > CURRENT_TIMESTAMP()
0
 
LVL 17

Accepted Solution

by:
HuyBD earned 125 total points
ID: 22764885
try this
UPDATE SMSIN_copy

SET validDate = date_add(realdate,interval -6 hour)

where realdate > CURRENT_TIMESTAMP()

Open in new window

0
 

Author Comment

by:kenuk110
ID: 22764889
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
0
 

Author Closing Comment

by:kenuk110
ID: 31508169
Brilliant, works perfectly. Cheers.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now