srk
srk

Reputation: 435

How to change a 'date' in Char format to date format in teradata SQL?

I have a column date like date CHAR(7) CHARACTER SET LATIN NOT CASESPECIFIC, where i have some values like 2010-12, 2011-10, etc. i want to change these into the date format yyyy/mm . How do i do it? Thanks

Upvotes: 4

Views: 5589

Answers (1)

dnoeth
dnoeth

Reputation: 60482

Simply apply a FORMAT dring the CAST:

SELECT CAST('2010-12' AS DATE FORMAT 'YYYY/MM')

This returns a valid date with the day set to the 1st of this month.

Upvotes: 5

Related Questions