Avatar of AFIF JABBADO
AFIF JABBADO
Flag for United States of America asked on

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

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
Microsoft SQL Server 2005Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Kyle Abrahams

8/22/2022 - Mon
Yagya Shree

Please use below query

Select getdate+2
Select enddate-2
Kyle Abrahams

select * from subscriptions
where datediff(d, getdate(), subscription_date) > 2
AFIF JABBADO

ASKER
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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Kyle Abrahams

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question