Hi, I am trying to get the number of day between two dates. (A date and today's date)
The date is a string in the DD/MM/YYYY format.
I encoded the following function in SQL SSMS but I have a issue, as I select all my Date column, I got an error when I execute.
SQL Code:
--Ma fonction--
DECLARE @Day integer --
DECLARE @Month integer --The date from dd/mm/yyyy format
DECLARE @Year integer --
DECLARE @Now date --The date of today
SET @Day = (SELECT SUBSTRING(date,1,2) as extractstring FROM Donnees_MET)
SET @Month = (SELECT SUBSTRING(date,4,2) as extractstring FROM Donnees_MET)
SET @Year = (SELECT SUBSTRING(date,7,4) as extractstring FROM Donnees_MET)
SET @Now = (SELECT CONVERT (date, GETDATE()))
SELECT datediff(DAY, @Year-@Month-@Day, @Now) --Number of days between the date and today
I don't know how I can loop on each result one by one to return the number of day between the date and today. (This is in order to send a notification after 30 days in a vb.net app)
Thank you for your help !