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

Member

by lew , in category: MySQL , 5 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by wilmer.lemke , 5 months 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.

Related Threads:

How to insert date in yyyy-mm -dd hh24:mi:ss in oracle?
How to convert strings to a 'mm/dd/yyyy' format in teradata?
How to convert 'dd-mm-yyyy' to 'dd-mmm-yyyy' in postgresql?
How to convert timestamp to yyyy-mm-dd hh24:mi:ss format in oracle?
How to convert yyyy-mm-dd hh:mm:ss to hh:mm:ss in mysql?
How set the datepicker in moment.js to yyyy-mm-dd?