Last post Oct 02, 2018 03:23 PM by mgebhard
Sep 12, 2018 09:02 AM|jonnygareth30|LINK
I have a stored procedure which retrieves all dates 30 days or less on an expiry date but I am wondering if it is possible to only return values where the date is only 30 days days before? I would only like the records displayed that are exactly 30 days
before the expiry date rather than display all dates less than 30 days before also.
Any help would be greatly appreciated.
Sep 12, 2018 10:00 AM|jonnygareth30|LINK
My apologies, I have managed to do this by using the below code within MSSQL:
WHERE ExpiryDAte = CAST(DATEADD(d, 30, GETDATE()) AS DATE)
Sep 27, 2018 07:20 AM|tdinpsp|LINK
Minor tweak to jonnygareth30's response; -30 not 30.
Oct 02, 2018 02:11 PM|jonnygareth30|LINK
Thanks for your advice but when trying -30 for instead of 30 no results are displayed. When leaving as 30 I get the correct results displayed.
Oct 02, 2018 03:23 PM|mgebhard|LINK
WHERE DATEDIFF(d, GETDATE(), ExpiryDate) = 30