How To Get Previous DATE in SQL - SQL previous date
Let's think of a scenario in which you want to get the previous date (the date before today) in SQL here is the query to get that.
Oracle - Get previous date in Oracle
You can use SYSDATE to get the current date. Then subtract 1 day from the current date.
SELECT SYSDATE - 1 FROM dual;
MySQL - Get previous date in Oracle
Get the current date using CURDATE() and you can use DATE_SUB() to subtract the date and you can use DATE_ADD() to add the date.
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY);
You can get the tomorrow date using DATE_ADD().
SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY);
MSSQL - Get previous date in Oracle
You can use GETDATE() to get the current date and you can use DATEADD() to subtract the date.
SELECT DATEADD(DAY, -1, GETDATE());
Comments
Post a Comment