SQL Server How to parse a string value to a date in a coalesce expression/parameter?

8oomwypt  于 2023-05-21  发布在  其他
关注(0)|答案(1)|浏览(188)

We have birthdate field in first layer with data type as 'string' then the data flows to 2nd layer where the data type for the same field is set as 'date'. This results in having 'null' for the birthdate field in 2nd layer. I'm trying to use coalesce and parse_date functions to parse all different date formats (from the first layer) to the birthdate field (in the 2nd layer) but get 'no matching signature ...' error which means it doesn't let me parse a string to a date.

Any idea how to do this? We want to make sure any date format entered in the first layer (as string) will be shown in the 2nd layer (as date)

4nkexdtk

4nkexdtk1#

Use CONVERT function I don't know what format have your birthdate field but here you can find a lot of transformation patterns https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/

相关问题