Solved

curdate time zone offset

Posted on 2006-11-27
6
1,710 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

791 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