?
Solved

SQL Server Determine if date is recurrance date

Posted on 2016-10-26
3
Medium Priority
?
78 Views
Last Modified: 2016-10-26
I need to determine if GETDATE()  is exactly on a two week interval from a specific date

Example...
A person has a payment to make
First Payment was on July 20th 2010
Interval is Bi-Weekly (Every 2 weeks)

Is today THAT "every 14 days" date? Yes/No
0
Comment
Question by:lrbrister
[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
  • 2
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 41861034
<Air code.  I do my own stunts too>

SELECT CASE 
  WHEN DATEADD(d, 14, FirstPaymentDate) = CAST(GETDATE() as date) THEN 'Yes'
  ELSE 'No' END as MakeUpAColumnNameHere

Open in new window

0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41861039
... or if we're talking 'If this is on the 14th date somewhere out in the future' then use Modulo...

SELECT CASE 
  WHEN DATEDIFF(d, FirstPaymentDate, CAST(GETDATE() as date)) % 14 = 0 THEN 'Yes'
  ELSE 'No' END as MakeUpAColumnNameHere

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 41861053
You answered my question correctly
I will have a follow-up question
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

741 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