Unexpected Sort Order When Querying DATE Data Type Columns - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Unexpected Sort Order When Querying DATE Data Type Columns

Using the ORDER BY clause to query columns with the DATE data type may yield results in which the order of the returned values seem to be out of order.

The factors that contribute to this type of unexpected result are:

  • DATE time values are stored by the system on disk in UTC time, not local time.
  • UTC time values are used to sort the column values, not the local time values.
  • DATE time values are affected by the system time zone setting, which can be set using TimeZoneString or the DBSControl general field 16.
  • DATE time values that cross the date boundary are adjusted based on the time zone offset for the system time zone (the time zone offset varies depending on the time zone).
  • For possible workarounds, see “Workarounds” on page 208.