t-sql date help

jfreeman2010
jfreeman2010 used Ask the Experts™
on
I need help on t-sql date:

I have this: DATEDIFF(DAY,StartDate, getdate())  =  '14' to find the startdate is 14 days pass.

 then I also need to find those that occur every 7 days thereafter, etc 21 days, 28 days, 35 days

Can someone please help?

Thank you!!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bradley FoxLAN/WAN Systems Administrator
Commented:
WHERE (datediff(day,StartDate,getdate()) % 7 = 0)

Open in new window


This will get any where the result from your datediff function divides evenly by 7
Commented:
How about something like this.

WHERE
   DATEDIFF(DAY,startDate,getdate()) = 14 OR (DATEDIFF(DAY,startDate,getdate())  > 14 AND DATEDIFF(DAY,startDate,getdate())%7 = 0)

Author

Commented:
yes, it works.  Thank you very much!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial