• Status: Solved
• Priority: Medium
• Security: Public
• Views: 242

# find if today is a recurring day

Hi:

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.
0
myyis
• 3
• 2
1 Solution

Billing EngineerCommented:
step 1: number of days between schedule start and today, using datediff
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_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:
http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_mod
0

Author Commented:
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.
0

Billing EngineerCommented:
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');
``````

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

returns this data:
`````` 	DATEDIFF(NOW(), D) 	MOD(DATEDIFF(NOW(), D), 10)
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
``````

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.
0

Author Commented:
thank you
0

Author Commented:
Hi Guy,
Can you have a look at this?
http://www.experts-exchange.com/Database/MySQL/Q_28599434.html#a40558061
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

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