首页 > 解决方案 > How can I switch the Month and Day when the column format is M/D/Y?

问题描述

I am not sure if this has already been answered but I could not find anything.

I am trying to convert the column of dates from MM/DD/YYYY to DD/MM/YYYY.

I must confess that I don't even know where to begin on this. I was thinking I might try an update statement but I am unsure as to how to format it. Any help would be appreciated.

标签: sqlsql-servertsql

解决方案


You need to do two level of conversation :

select convert(varchar(12), convert(date, datecol, 101), 103)

In general, you need to fix the data-type (if that is in your hand) instead of doing conversation in SQL. Date formatting should be done at the presentation layer.


推荐阅读