Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

5 Top Teradata DATE functions read now

Teradata Functions
The following are the list of DATE functions. These are very frequently being used in Teradata.

Current DATE

The following statement requests the current system date:
SELECT CURRENT_DATE; The system responds with something like the following:
Date -------- 01/12/28

Changing Current DATE to DATE as you expected

To change the default output format of the CURRENT_DATE result, use Teradata explicit conversion syntax and specify the FORMAT phrase. For example, the following statement requests the current time and specifies a format that is different from the default:

SELECT CURRENT_DATE (FORMAT 'MMMBDD,BYYYY');
The result looks like this: Date ------------ May 31, 2007

Current Time

The following statement requests the current system time and current session Time Zone displacement:

SELECT CURRENT_TIME; The system responds with something like the following:
Current Time(0) --------------- 15:53:34+00:00

Changing Current TIME

To change the default output format of the CURRENT_TIME result, use Teradata explicit conversion syntax and specify the FORMAT phrase.

For example, the following statement requests the current time and specifies a format that is different from the default:

SELECT CURRENT_TIME (FORMAT 'HH:MIBT');
The result looks like this: Current Time(0) --------------- 02:29 PM

Also Read: 3 Books to read by every Software Engineer

Current TIMESTAMP

CURRENT_TIMESTAMP Fields The fields in CURRENT_TIMESTAMP are:
• YEAR
• MONTH
• DAY
• HOUR
 • MINUTE
• SECOND
 • TIMEZONE_HOUR
• TIMEZONE_MINUTE

Example to Select Current TIMESTAMP

The following statement requests the system timestamp and session Time Zone displacement: SELECT CURRENT_TIMESTAMP;

The system responds with something like the following: Current TimeStamp(6) -------------------------------- 2001-11-27 15:53:34.910000+00:00

Example to ADD_MONTHS

This statement returns the current date plus 13 years.

SELECT ADD_MONTHS (CURRENT_DATE, 12*13);

Example to Extract Year from DATE

The following example returns the year, as an integer, from the current date.
SELECT EXTRACT (YEAR FROM CURRENT_DATE);



This post first appeared on SriniTera - Data Analysis Solutions, please read the originial post: here

Share the post

5 Top Teradata DATE functions read now

×

Subscribe to Srinitera - Data Analysis Solutions

Get updates delivered right to your inbox!

Thank you for your subscription

×