Home > Enterprise >  Convert dates to dates with a first day of the month in Snowflake
Convert dates to dates with a first day of the month in Snowflake

Time:01-27

There are dates, for example:

'2022-10-11'
'2022-01-20'
'2022-12-31'

How to convert them to the following dates in Snowflake?

'2022-10-01'
'2022-01-01'
'2022-12-01'

Thank you!

CodePudding user response:

It could be achieved with DATE_TRUNC function:

SELECT DATE_TRUNC('MONTH',  col_name) FROM ...
  • Related