Solved

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

Posted on 2013-06-16
3
409 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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