Solved

How to minus 6 hours from a timestamp?

Posted on 2008-10-20
4
1,370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Upcoming Webinar: Securing your MySQL/MariaDB data

Join Percona’s Chief Evangelist, Colin Charles as he presents Securing your MySQL®/MariaDB® data on Tuesday, July 11, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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