Solved

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

Posted on 2012-12-21
4
695 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
[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
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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