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:
  1. --Ma fonction--
  2. DECLARE @DAY INTEGER    --
  3. DECLARE @MONTH INTEGER  --The date from dd/mm/yyyy format
  4. DECLARE @YEAR INTEGER   --
  5. DECLARE @Now DATE   --The date of today
  6.  
  7. SET @DAY = (SELECT SUBSTRING(DATE,1,2) AS extractstring FROM Donnees_MET)
  8. SET @MONTH = (SELECT SUBSTRING(DATE,4,2) AS extractstring FROM Donnees_MET)
  9. SET @YEAR = (SELECT SUBSTRING(DATE,7,4) AS extractstring FROM Donnees_MET)
  10. SET @Now = (SELECT CONVERT (DATE, GETDATE()))
  11.  
  12. 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 !