I want to convert string column of format 'mm-yyyy' to timestamp.
Asked
Active
Viewed 187 times
1 Answers
0
Try this following logic. As you have only Month and Year value in your string, I have added the static date 01 to each date to generate the DATETIME value.
select
CAST(
CONCAT(right('06-2019',4) , '-', left('06-2019', 2),'-01') AS DATETIME
);

mkRabbani
- 16,295
- 2
- 15
- 24
-
Throws error `Incorrect parameters in the call to stored function CAST` when executed. Can you please correct it. – XING Nov 07 '19 at 07:08
-
Updated. There were issue basically related to spacing between lines. – mkRabbani Nov 07 '19 at 07:39