17.10 - Default Format - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

The result of a CASE expression is displayed using the default format for the resulting data type. The result of a CASE expression does not apply the explicit format that may be defined for a column appearing in a THEN/ELSE expression.

Consider the following table definition:

   CREATE TABLE duration
      (i INTEGER
      ,start_date DATE FORMAT 'EEEEBMMMBDD,BYYYY'
      ,end_date DATE FORMAT 'DDBM3BY4' );

Assume the default format for the DATE data type is 'YY/MM/DD'.

The following query displays the result of the CASE expression using the 'YY/MM/DD' default DATE format, not the format defined for the start_date or end_date columns:

   SELECT i, CASE
              WHEN i=1 
              THEN start_date
              WHEN i=2 
              THEN end_date
             END
   FROM duration
   ORDER BY 1;