How to Find Yesterday's Date in SQL Server

preview_player
Показать описание
If you find this SQL tutorial useful please LIKE and SUBSCRIBE!

In this video I show you how to retrieve yesterday's date from a SQL Server query.

00:00 - Introduction
00:06 - Today's Date
00:32 - Yesterday's Date
01:28 - Yesterday's Day Name

Useful transact SQL queries:

This find's today's date:

SELECT GETDATE() as 'Today'

We can use the DATEADD function to find yesterday's date from today's date by substracting one day from today's date:

SELECT DATEADD(day, -1, GETDATE()) as 'Yesterday'

Bonus query... use the following SQL to find out the day name for yesterday using the DATENAME and DATEADD functions:

SELECT DATENAME(dw, DATEADD(day, -1, GETDATE())) as 'Yesterday Day Name'

Рекомендации по теме
Комментарии
Автор

What problems or issues are you having with SQL? Drop a comment below and I'll make more videos on whatever topic you're having problems with. Happy coding :) ... Brett

codingwithbrett
Автор

how can we find yesterday's record in the database?

hindi-english