Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

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

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
tjyoung
Asked:
tjyoung
  • 2
1 Solution
 
Ray PaseurCommented:
$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
 
tjyoungAuthor Commented:
Many thanks as always.
0
 
Ray PaseurCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now