Usage Notes - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-30
dita:mapPath
tpt1555966086716.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantageā„¢

CURRENT_TIME returns the current time when the request started. If CURRENT_TIME is invoked more than once during the request, the same time is returned. The time returned does not change during the duration of the request.

If you specify CURRENT_TIME without the AT clause or CURRENT_TIME AT LOCAL, then the value returned depends on the setting of the DBS Control flag TimeDateWZControl as follows:

  • If the TimeDateWZControl flag is enabled, CURRENT_TIME returns a time constructed from the session time and session time zone.
  • If the TimeDateWZControl flag is disabled, CURRENT_TIME returns a time constructed from the time value local to Vantage and the session time zone.

The following occurs when using CURRENT_TIME with daylight saving time (DST):

  • When TimeDateWZControl flag is enabled and the session time zone is defined with a time zone string that follows different Daylight Saving Time and standard time zone displacements, then CURRENT_TIME AT LOCAL gives TIME value corresponding to Standard time zone rather than the Daylight Saving Time time zone.
  • During the Daylight Saving Time period, CURRENT_TIME AT LOCAL follows Standard time zone, whereas CURRENT_TIME follows the Daylight Saving Time zone. During Standard time zone period, both CURRENT_TIME and CURRENT_TIME AT LOCAL follow the standard time zone.

For example, during DST period:

BTEQ -- Enter your SQL request or BTEQ command: 
.os date       
Sat Sep  5 14:00:23 PDT 2015

BTEQ -- Enter your SQL request or BTEQ command: 
.os date -u
Sat Sep  5 21:00:26 UTC 2015

BTEQ -- Enter your SQL request or BTEQ command: 
select current_time, current_time at local;


*** Query completed. One row found. 2 columns returned. 
 *** Total elapsed time was 1 second.

Current Time(0)  Current Time(0) AT LOCAL
---------------  ------------------------
14:00:30-07:00            13:00:30-08:00

During Standard Time Zone Period:

BTEQ -- Enter your SQL request or BTEQ command: 
.os date
Fri Nov  6 04:18:04 PST 2015

BTEQ -- Enter your SQL request or BTEQ command: 
.os date -u
Fri Nov  6 12:18:07 UTC 2015

BTEQ -- Enter your SQL request or BTEQ command: 
select current_time, current_time at local;


*** Query completed. One row found. 2 columns returned. 
 *** Total elapsed time was 1 second.

Current Time(0)  Current Time(0) AT LOCAL
---------------  ------------------------
04:18:20-08:00            04:18:20-08:00
If CURRENT_TIME is used in a stored procedure, the procedure must be recompiled whenever the DBS Control fields System TimeZone Hour or System TimeZone Minute are changed. Recompiling stored procedures is not necessary if a time zone string is set using the tdlocaledef utility.