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

Posted on 2012-12-21
Medium Priority
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
Question by:AFIF JABADO
  • 2
LVL 13

Expert Comment

by:Yagya Shree
ID: 38714422
Please use below query

Select getdate+2
Select enddate-2
LVL 41

Expert Comment

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

Author Comment

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
LVL 41

Accepted Solution

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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 part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

624 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