Home > Software engineering >  How to merge the dates into one column?
How to merge the dates into one column?

Time:10-27

I have the year, month, day in separate columns and I want to merge them all into one column in snowflake

CodePudding user response:

You should use the DATE_FROM_PARTS function:

select date_from_parts(1977, 8, 7);

Reference: DATE_FROM_PARTS

CodePudding user response:

Create a string expression then use the To_Date Function. For example:

set (day, month, year) = ('26', '10', '2021');
set strDate = concat(year, '-', month, '-', day);
select to_date(strDate)

CodePudding user response:

select year||'-'||month||'-'||day from table

where year, month and day are column names for corresponding data.

  • Related