find if today is a recurring day

Posted on 2015-01-19
Last Modified: 2015-01-19

Let's say on 10/10/2014 I have created a recurring task. It recurs on every 10 days.
How can I understand if today there is a recurring task?

Thank you.
Question by:myyis
  • 3
  • 2
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
step 1: number of days between schedule start and today, using datediff

step 2: use the modulo function to see if the remainder of the division (datediff ...) and the (10 days) divisor gives 0 or not:

Author Comment

Comment Utility
I see that it will be difficult for me to go over the steps. You make me super happy if you write the  query,
thank you very much.
LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
let's consider this table:
create table test(d date);
insert into test values('2014-10-10');
insert into test values('2014-10-11');
insert into test values('2014-10-12');
insert into test values('2014-10-13');

Open in new window

then, this query
select d
, datediff(now(), d)
, mod(datediff(now(), d), 10) 
from test;

Open in new window


returns this data:
October, 10 2014 00:00:00+0000 	101 	1
October, 11 2014 00:00:00+0000 	100 	0
October, 12 2014 00:00:00+0000 	99 	9
October, 13 2014 00:00:00+0000 	98 	8

Open in new window

where only 2014-10-11 has a remainder of 0, so that one, as start date, would mean that today is a recurring 10 day interval date, or for 2014-10-10, yesterday would have been such a date.

Author Comment

Comment Utility
thank you

Author Comment

Comment Utility
Hi Guy,
Can you have a look at this?
Thank you.

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Creating and Managing Databases with phpMyAdmin in cPanel.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

16 Experts available now in Live!

Get 1:1 Help Now