Multiple choice technology

Find the function that returns the date of the previous year when compared to a particular date.

  1. dateadd(year,1,getdate())

  2. datediff(year,1,getdate())

  3. dateadd(year,-1,getdate())

  4. datediff(year,-1,getdate())

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The DATEADD function in SQL Server adds a specified interval to a date. To get the previous year's date, we need to subtract 1 year using DATEADD(year, -1, GETDATE()). Option A adds 1 year (future), while Option C correctly subtracts 1 year to get the previous year's date. DATEDIFF calculates the difference between dates, it doesn't add or subtract intervals.