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]
ID: 40557683
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

ID: 40557708
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
ID: 40557723
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

ID: 40557903
thank you

Author Comment

ID: 40558686
Hi Guy,
Can you have a look at this?
Thank you.

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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