Solved

SQL Server Determine if date is recurrance date

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

707 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