Solved

tsql check if datediff is 2 days only btween enddate and getdate

Posted on 2012-12-21
4
692 Views
Last Modified: 2012-12-21
i want to use the function datediff to match all record whe have difference btween the enddate end current date is 2

for example each record has a expirydate i want to gets all records where the subscription end after 2 days
0
Comment
Question by:afifosh
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Yagya Shree
ID: 38714422
Please use below query

Select getdate+2
Select enddate-2
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 38714424
select * from subscriptions
where datediff(d, getdate(), subscription_date) > 2
0
 
LVL 1

Author Comment

by:afifosh
ID: 38714430
i want only get if is equal to 2 !! for automatic renew the subscription
if the expiration end after 2 days i will send to the user a notification not > 2
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 38714444
select * from subscriptions
where datediff(d, getdate(), expiry_date) = 2
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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