?
Solved

t-sql date help

Posted on 2012-12-27
3
Medium Priority
?
276 Views
Last Modified: 2012-12-27
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!!
0
Comment
Question by:jfreeman2010
3 Comments
 
LVL 22

Assisted Solution

by:mcsween
mcsween earned 1000 total points
ID: 38724189
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
0
 
LVL 15

Accepted Solution

by:
tim_cs earned 1000 total points
ID: 38724193
How about something like this.

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

Author Comment

by:jfreeman2010
ID: 38724231
yes, it works.  Thank you very much!!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

840 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