In this article, we will learn how to get yesterday and tomorrow in SQL Server.
How to Get First and Last Day of a Week in SQL Server
How to Get First and Last Day of a Month in SQL Server
How to Get First and Last Day of a Month in SQL Server using EOMONTH Function
To get the Yesterday with Time of SQL Server, a statement is as follows:
SELECT DATEADD(d,-1,GETDATE()) as Yesterday;
Yesterday
------------------------------
2019-09-19 12:33:55.307
To get Yesterday without Time of SQL Server, a statement is as follows:
SELECT DATEADD(day,DATEDIFF(day,0,GETDATE())-1,0) as Yesterday
Yesterday
------------------------------
2019-09-19 00:00:00.000
To get Tomorrow without Time of SQL Server, a statement is as follows:
SELECT DATEADD(day, 1, GETDATE()) as Tomorrow;
Tomorrow
------------------------------
2019-09-21 12:33:55.307
To get Tomorrow without Time of SQL Server, a statement is as follows:
SELECT DATEADD(day,DATEDIFF(day,0,GETDATE())+1,0) as Tomorrow;
Tomorrow
-------------------------------
2019-09-21 00:00:00.000
I hope this article will help you to understand how to get yesterday and tomorrow in SQL Server.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments