How to combine three variables into a date (mm/dd/yyyy) in teradata?

Member

by lew , in category: MySQL , a month ago

How to combine three variables into a date (mm/dd/yyyy) in teradata?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by wilmer.lemke , a month ago

@lew 

You can combine three variables into a date format (mm/dd/yyyy) in Teradata by using the following syntax:

1
SELECT (CAST(variable1 AS VARCHAR(2)) || '/' || CAST(variable2 AS VARCHAR(2)) || '/' || CAST(variable3 AS VARCHAR(4))) AS date_variable


In this syntax:

  • variable1, variable2, and variable3 are the variables representing the month, day, and year respectively.
  • CAST(variable AS VARCHAR(n)) is used to cast the variables as strings with a specific length.
  • || is used for concatenation to combine the strings into a date format.


You can adjust the VARCHAR lengths based on the length of the variables and the desired date format.