Solved

curdate time zone offset

Posted on 2006-11-27
6
1,706 Views
Last Modified: 2012-06-21
How would I make this query subtract 3 hours to offset a time zone difference? Our server which holds the data is on EST but I want the data pulled from this query to be PST. Thank you.

$t_query = "SELECT SUM(Total) AS num FROM orders WHERE date_purchased > CURDATE()";
0
Comment
Question by:pkromer
  • 4
  • 2
6 Comments
 
LVL 30

Expert Comment

by:todd_farmer
ID: 18021824
$t_query = "SELECT SUM(Total) AS num FROM orders WHERE date_purchased > (CURDATE() - INTERVAL 3 HOURS)";
0
 

Author Comment

by:pkromer
ID: 18021872
I get an error when i test that...

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'HOURS)' at line 1
0
 

Author Comment

by:pkromer
ID: 18021884
btw, we are using PHP Version 4.3.10
0
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.

 

Author Comment

by:pkromer
ID: 18021895
and MySQL Client API version  4.0.16  
0
 
LVL 30

Accepted Solution

by:
todd_farmer earned 125 total points
ID: 18021910
Sorry about that:

$t_query = "SELECT SUM(Total) AS num FROM orders WHERE date_purchased > (CURDATE() - INTERVAL 3 HOUR)";

mysql> select curdate() - interval 3 hours;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hours' at line 1

mysql> select curdate() - interval 3 hour;
+-----------------------------+
| curdate() - interval 3 hour |
+-----------------------------+
| 2006-11-26 21:00:00         |
+-----------------------------+
1 row in set (0.05 sec)
0
 

Author Comment

by:pkromer
ID: 18021956
perfect. Thank you very much.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
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…

778 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