{"id":1333,"date":"2022-06-18T16:02:30","date_gmt":"2022-06-18T23:02:30","guid":{"rendered":"https:\/\/www.1keydata.com\/blog\/?p=1333"},"modified":"2022-06-18T16:02:30","modified_gmt":"2022-06-18T23:02:30","slug":"todays-date-in-sql","status":"publish","type":"post","link":"https:\/\/www.1keydata.com\/blog\/todays-date-in-sql.html","title":{"rendered":"Today&#8217;s Date in SQL"},"content":{"rendered":"\n<p>One use case that happens often in SQL is the need to retrieve today&#8217;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. <\/p>\n\n\n\n<p>Unfortunately there is no standard SQL that allows you to retrieve today&#8217;s date across different database systems. So in this post we have gathered the SQL statement needed to retrieve today&#8217;s date for the most popular database systems:<\/p>\n\n\n\n<p><u>Oracle<\/u><\/p>\n\n\n\n<p><code>SELECT SYSDATE FROM DUAL;<\/code><\/p>\n\n\n\n<p><u>SQL Server<\/u><\/p>\n\n\n\n<p><code>SELECT GETDATE();<\/code><\/p>\n\n\n\n<p><u>MySQL<\/u><\/p>\n\n\n\n<p><code>SELECT CURDATE();<\/code><\/p>\n\n\n\n<p><u>DB2<\/u><\/p>\n\n\n\n<p><code>SELECT current date FROM sysibm.sysdummy1;<\/code><\/p>\n\n\n\n<p><u>Hive<\/u><\/p>\n\n\n\n<p><code>SELECT CURRENT_DATE;<\/code><\/p>\n\n\n\n<p><u>SparkSQL<\/u><\/p>\n\n\n\n<p><code>SELECT CURRENT_DATE or SELECT CURRENT_DATE();<\/code><\/p>\n\n\n\n<p><u>BigQuery<\/u><\/p>\n\n\n\n<p><code>SELECT CURRENT_DATE;<\/code><\/p>\n\n\n\n<p><u>PostgreSQL<\/u><\/p>\n\n\n\n<p><code>SELECT CURRENT_DATE;<\/code><\/p>\n\n\n\n<p><u>SQLite<\/u><\/p>\n\n\n\n<p><code>SELECT DATE();<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One use case that happens often in SQL is the need to retrieve today&#8217;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&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[247],"tags":[],"_links":{"self":[{"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/posts\/1333"}],"collection":[{"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/comments?post=1333"}],"version-history":[{"count":5,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions"}],"predecessor-version":[{"id":1348,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions\/1348"}],"wp:attachment":[{"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/media?parent=1333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/categories?post=1333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.1keydata.com\/blog\/wp-json\/wp\/v2\/tags?post=1333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}