lohith ramineni
lohith ramineni

Reputation: 57

How do I convert this to Snowflake SQL?

My T SQL -
left(convert(char,Month,111),7) "Year-Mon"

Below is the error I'm getting Error: invalid identifier 'CHAR'

Upvotes: 1

Views: 75

Answers (1)

Koushik Roy
Koushik Roy

Reputation: 7387

You can use this

to_char(to_date(Month,'yyyy/mm/dd'),'yyyy-mm') "Year-Mon"

From your question, I assumed,
Month is a string in yyyy/mm/dd format.
And you are expecting a string in yyyy-mm format.

Upvotes: 1

Related Questions