Solved

curdate time zone offset

Posted on 2006-11-27
6
1,675 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
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.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now