SELECT DISTINCT [WHO].PERSONNUM EMPID
, [SHIFTSTARTDATE] STDT
, [SHIFTENDDATE] ENDDT
, GETDATE() [WHEN]
FROM [WFCDB].[dbo].[SHIFTASSIGNMNT] AS [WHN]
LEFT OUTER JOIN [WFCDB].[dbo].VP_ALLPERSONv42 AS [WHO]
ON [WHN].EMPLOYEEID = [WHO].EMPLOYEEID
WHERE DATEPART(m, [SHIFTSTARTDATE]) = DATEPART(m, DATEADD(m, -1, getdate()))
AND DATEPART(yyyy, [SHIFTSTARTDATE]) = DATEPART(yyyy, DATEADD(m, -1, getdate()))
AND DELETEDSW <> 1)
答案 0 :(得分:2)
答案 1 :(得分:0)
您可以使用此
SELECT convert(varchar, getdate(), 104)
检查此链接其他格式 https://anubhavg.wordpress.com/2009/06/11/how-to-format-datetime-date-in-sql-server-2005/