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
Exercise instructions
- Create a function named
GetYesterday()
with no input parameters thatRETURNS
adate
data type. - Use
GETDATE()
andDATEADD()
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