Solved

SQL Server Determine if date is recurrance date

Posted on 2016-10-26
3
68 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 65

Accepted Solution

by:
Jim Horn earned 500 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 65

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

Technology Partners: 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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

738 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