Solved

find if today is a recurring day

Posted on 2015-01-19
5
164 Views
Last Modified: 2015-01-19
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
Comment
Question by:myyis
[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
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40557683
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
 
LVL 1

Author Comment

by:myyis
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.
0
 
LVL 143

Accepted Solution

by:
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:
 	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

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

Author Comment

by:myyis
ID: 40557903
thank you
0
 
LVL 1

Author Comment

by:myyis
ID: 40558686
Hi Guy,
Can you have a look at this?
http://www.experts-exchange.com/Database/MySQL/Q_28599434.html#a40558061
Thank you.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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 …
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

627 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