简体   繁体   中英

Update some values in a column based on a condition SQL Server

I have a varchar column that stores dates, but the formatting is very messy. I have dates in formats mm/dd/yyyy , m/d/yyyy and yyyy-ww-0 . I want to have everything in format mm/dd/yyyy , but I'm not sure how to change the values that are m/d/yyyy and make them 0m/0d/yyyy (and update the column in the original dataset), and what to do with the dates yyyy-ww-0 .

try this

select format(cast([column name] as date),'mm/dd/yyyy') from [table name]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM