One use case that happens often in SQL is the need to retrieve today’s date. This could be you are doing an analysis based on recent data, or it could be you are building a script that needs to retrieve the date dynamically.
Unfortunately there is no standard SQL that allows you to retrieve today’s date across different database systems. So in this post we have gathered the SQL statement needed to retrieve today’s date for the most popular database systems:
Oracle
SELECT SYSDATE FROM DUAL;
SQL Server
SELECT GETDATE();
MySQL
SELECT CURDATE();
DB2
SELECT current date FROM sysibm.sysdummy1;
Hive
SELECT CURRENT_DATE;
SparkSQL
SELECT CURRENT_DATE or SELECT CURRENT_DATE();
BigQuery
SELECT CURRENT_DATE;
PostgreSQL
SELECT CURRENT_DATE;
SQLite
SELECT DATE();