Solved

How to minus 6 hours from a timestamp?

Posted on 2008-10-20
4
1,305 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

20 Experts available now in Live!

Get 1:1 Help Now