Skip to main content

Datometry Documentation

Enable Support for Leap Seconds

Teradata supports leap seconds, whereas many other databases do not. The leap_second_literals hint lets you enable the handling of leap seconds, in which there are greater than 59 seconds in the following data types:

  • TIME

  • TIME WITH TIME ZONE

  • TIMESTAMP

  • TIMESTAMP WITH TIME ZONE

Teradata accepts the seconds value in a range from 0 to 61. However, most databases will not accept a seconds value that is greater than 59.

To learn more about Teradata support for leap seconds, see TIME Data Type in the Teradata documentation.

Note

Supporting leap seconds may result in slightly slower query performance due to the additional system overhead needed to process them.

The syntax for leap_second_literals is:

leap_second_literals = true | false

where:

Parameter

Description

true

Enables the use of leap seconds with a value greater than 59 seconds to be used.

false

Disables the use of Teradata leap seconds, and uses the current database's handling of seconds for the TIME, TIME WITH TIME ZONE, TIMESTAMP, and TIMESTAMP WITH TIME ZONE data types. This is the default behavior if leap_second_literals is not not specified.

Example 16. Enable Teradata Leap Second Support Using a Global Setting

You can specify leap_second_literals as a global setting in the Hyper-Q configuration file (dtm.ini).

If you want to apply leap_second_literals to all SQL statements, the preferred method is to specify it as a global setting. The leap_second_literals property is in the [gateway] section of the dtm.ini file, which defines the connection to the target data warehouse.

"gateway".leap_second_literals = true


Example 17. Enable Teradata Leap Second Support Using a Hyper-Q SQL Hint

To enable the Teradata leap second behavior as a SQL hint within a query, specify the following Hyper-Q hint at the request level.

INSERT INTO tablename
-- @dtm_leap_second_literals = true
VALUES('9999-11-30 23:59:61.123456');

The hint must be enclosed in the SQL statement to prevent the client querying the database from removing the comment before sending the statement to Hyper-Q. Regardless of its location in the statement text, the hint applies to the entire statement.