Solved

How to minus 6 hours from a timestamp?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Whether to use true/false, yes/no or 0/1 11 67
PHP: concatenate query 13 79
MS Access - need to reduce row size 25 61
two ways encryption with php 3 37
Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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