{"id":1006,"date":"2021-10-02T21:19:38","date_gmt":"2021-10-02T15:49:38","guid":{"rendered":"https:\/\/techieshouts.com\/home\/?p=1006"},"modified":"2022-07-30T19:04:06","modified_gmt":"2022-07-30T13:34:06","slug":"teradata-get-current-date-and-time","status":"publish","type":"post","link":"https:\/\/techieshouts.com\/home\/teradata-get-current-date-and-time\/","title":{"rendered":"Teradata Get Current date and Time"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Teradata\" target=\"_blank\" rel=\"noopener\">Teradata<\/a>, while writing queries, it is always a good practice to make sure the query is capable of creating Point In Time(PIT) dataset. This is to make sure that the usage of DATE in the code is not hard-coded to produce the same record set every time. <\/p>\n\n\n\n<p>Analysts and Data scientists used to create queries to simulate record sets for the historic dates. This can be achieved by passing the past date to the queries. This is mainly to check the model or dataset that they are generating is accurate enough to serve the purpose. Now, if the user has used CURRENT_DATE in the code for date filtering or comparison, it is easy to change that to any historic date. <\/p>\n\n\n\n<h2>Get the current date using the DATE function<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"classic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT DATE as TODAY;<\/pre>\n\n\n\n<p>The above statement will give the value of today&#8217;s date. A screenshot of the output is given below<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"312\" height=\"150\" src=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image.png\" alt=\"\" class=\"wp-image-1007\" srcset=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image.png 312w, https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image-300x144.png 300w\" sizes=\"(max-width: 312px) 100vw, 312px\" \/><\/figure>\n\n\n\n<h2>Get Today&#8217;s date using CURRENT_DATE function<\/h2>\n\n\n\n<p>Teradata has another function that gives today&#8217;s date. It is the CURRENT_DATE function. There is no difference in the result between the DATE and CURRENT_DATE functions. Both will give the same result.<\/p>\n\n\n\n<p>SELECT CURRENT_DATE as TODAY;<\/p>\n\n\n\n<p>The above statement will also give the value of today&#8217;s date.<\/p>\n\n\n\n<h2>Get Current TimeStamp in Teradata<\/h2>\n\n\n\n<p>SELECT CURRENT_TIMESTAMP(0) as NOW;<\/p>\n\n\n\n<p>This will give the output in the &#8216;YYYY-MM-DD hh:mm:ss:milliseconds&#8217; format. A screenshot of the sample output is given below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"514\" height=\"150\" src=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image-1.png\" alt=\"\" class=\"wp-image-1008\" srcset=\"https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image-1.png 514w, https:\/\/techieshouts.com\/wp-content\/uploads\/2021\/10\/image-1-300x88.png 300w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/figure>\n\n\n\n<p>Also check,<\/p>\n\n\n\n<ol><li><a href=\"https:\/\/techieshouts.com\/home\/create-table-types-in-teradata-with-examples\/\">Create a table in Teradata with examples<\/a><\/li><li><a href=\"https:\/\/techieshouts.com\/home\/using-bteq-export-table-to-file-in-teradata\/\">Export Teradata table to file using BTEQ<\/a><\/li><li><a href=\"https:\/\/techieshouts.com\/home\/create-table-using-select-in-teradata\/\">Create a table using Select in Teradata<\/a><\/li><li><a href=\"https:\/\/techieshouts.com\/home\/teradata-get-table-ddl-with-the-table-name\/\">Get DDL using a table name in Teradata<\/a><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In Teradata, while writing queries, it is always a good practice to make sure the query is capable of creating Point In Time(PIT) dataset. This is to make sure that the usage of DATE in the code is not hard-coded to produce the same record set every time. Analysts and Data scientists used to create\u2026 <span class=\"read-more\"><a href=\"https:\/\/techieshouts.com\/home\/teradata-get-current-date-and-time\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[159,163,160,162,161],"_links":{"self":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/1006"}],"collection":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/comments?post=1006"}],"version-history":[{"count":3,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/1006\/revisions"}],"predecessor-version":[{"id":1217,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/1006\/revisions\/1217"}],"wp:attachment":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/media?parent=1006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/categories?post=1006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/tags?post=1006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}