转换为mm / dd / yyyy格式 [英] Converting to mm/dd/yyyy format
本文介绍了转换为mm / dd / yyyy格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为SF_Data的表,还有一个名为IN_Date的列,ID的数据看起来像这样:
I have a table called SF_Data and there is a column called IN_Date, ID the data looks like:
ID IN_Date
1 9/8/2010
2 26/04/2011
3 20/09/2010
IN_Date的数据类型为varchar(50)。
The datatatype of IN_Date is varchar(50).
我正在尝试将IN_Date转换为mm / dd / yyyy格式。我尝试这样做:
I am trying to convert the IN_Date to mm/dd/yyyy format. I tried doing this:
Select convert(varchar,IN_Date,103) From dbo.SF_Data
但格式仍然不变。谁能告诉我我要去哪里哪里
But still the format doesn't change. Can anyone tell me where I am going wrong
推荐答案
您需要转换才能将数据修复(正确的数据类型)之前格式...
You need a convert to fix the data (to the correct datatype) before formatting...
Select
convert(varchar,
convert(date, IN_Date, 103),
101)
from dbo.SF_Data
这篇关于转换为mm / dd / yyyy格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文