Sunday, 7 May 2017

5 Top Teradata DATE functions to read now

date functions in teradata

The following are the list of DATE functions. These are very frequently being used in Teradata. The following statement requests the current system date:

Current 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

SELECT CURRENT_TIME;

The system responds with something like the following:

Current Time(0) --------------- 15:53:34+00:00

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

Changing Current TIME

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


SELECT CURRENT_TIME (FORMAT 'HH:MIBT');

The result looks like this: Current Time(0) --------------- 02:29 PM


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

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

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);

No comments:

Post a Comment

Featured post

5 Top Teradata DATE functions to read now

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

Popular Posts