2008R2 TSQL:将dateadd从YYYY-MM-DD转换为MM / DD / YYYY

时间:2015-08-10 21:35:22

标签: tsql sql-server-2008-r2

我想将日期格式从2015-08-01转换为08/01/2015

我试过了:

DATEADD(DAY, 7 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)) as 'Week Ending'

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

您需要使用CONVERT功能。您要查找的具体格式为101

例如:

CONVERT(VARCHAR(10), DATEADD(DAY, 7 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)), 101) as 'Week Ending'