这是我的查询
select projectname,CONCAT([Budget Health],[ProjectBaseline0StartDate],[ProjectActualStartDate],[ProjectStartDate]) as budgethealth from [dbo].[MSP_EpmProject_UserView]
输出为:
projectname | budgethealth
abc |< 5% varianceApr 7 2015 8:00AMApr 7 2015 8:00AMApr 7 2015 8:00AM
我想要以下形式的预算健康信息:
<5% variance
Apr/07/2015
Apr/08/2015
Apr/08/2015
我想要删除时间并以这种格式显示日期。
答案1
您可以按如下方式格式化 DateTime:
CONVERT(数据类型(长度),表达式,样式)
前任:
CONVERT(varchar(11),[ProjectBaseline0StartDate])
完整查询:
select projectname,CONCAT([Budget Health],Convert(varchar(11),[ProjectBaseline0StartDate]),CONVERT(varchar(11),[ProjectActualStartDate]),CONVERT(varchar(11),[ProjectStartDate])) as budgethealth from [dbo].[MSP_EpmProject_UserView]
请查看详细信息和样式选项: http://www.w3schools.com/sql/func_convert.asp