5 Top Teradata DATE functions to read now

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

teradata date


You can find Teradata Date differences using Date functions

1. Current DATE

SELECT CURRENT_DATE;

The system responds with something like the following:
Date -------- 01/12/28


2. 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

3. 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:

4. 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:


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

Comments

Popular posts from this blog

SQL for Quantile Function in Teradata

3 Uses of SAMPLE function in Teradata

All You Need NULL Value Functions