Solved

Trying to get all id's whose DateTime records are 15 minutes from now

Posted on 2013-06-16
3
403 Views
Last Modified: 2013-06-16
Hi,
I'm setting up a cron function running every 15 minutes that checks a column called 'scheduled' for datetimes that are 15 minutes from now and retrieves each campaign_id so I can send out a reminder email about that upcoming campaign.

Records can be saved in 15 minute values only, for example:
2013-06-13 11:00:00 or 2013-06-13 11:15:00 or 2013-06-13 11:30:00 or 2013-06-13 11:45:00

Any idea what a query may look like?

mysql_query("SELECT campaign_id FROM messaging WHERE scheduled = ???...");

Any help would be much appreciated.
0
Comment
Question by:tjyoung
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
$future = date('c', strtotime('NOW + 15 MINUTES'));
$query = "SELECT campaign_id FROM messaging WHERE scheduled = '$future' ";

If you're actually using the MySQL extension, you may want to make a change.  PHP is removing support for MySQL.  This article explains why and what you must do to keep your scripts running.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
 
LVL 1

Author Closing Comment

by:tjyoung
Comment Utility
Many thanks as always.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Glad to help -- thanks for the points.  You might also find this article helpful.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

Best regards, ~Ray
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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 …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

14 Experts available now in Live!

Get 1:1 Help Now