Solved

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

Posted on 2013-06-16
3
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39251333
$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
ID: 39251340
Many thanks as always.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39251353
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 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