Get startedGet started for free

What was yesterday?

Create a function that returns yesterday's date.

This exercise is part of the course

Writing Functions and Stored Procedures in SQL Server

View Course

Exercise instructions

  • Create a function named GetYesterday() with no input parameters that RETURNS a date data type.
  • Use GETDATE() and DATEADD() to calculate yesterday's date value.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Create GetYesterday()
___ ___ GetYesterday()
-- Specify return data type
___ ___
AS
BEGIN
-- Calculate yesterday's date value
___(SELECT ___(day, -1, ___()))
END 
Edit and Run Code