如何将最小和最大与日期结合

时间:2019-06-13 01:39:02

标签: sql-server

我希望我的代码合并日期(格式为2/4/19),但是我在TimeIn中使用min,我不知道如何解决此问题(这是我要显示2/4 /的示例19 8:00)

Select  A.EmpID [X_TMSHT_EMPID],
        A.[RecordDate] [X_TMSHT_APPLY],
        CONCAT(A.[RecordDate], (MIN(IIF(ISNULL(CHARINDEX('I', A.[Entries], 0), -1) > 0, SUBSTRING(A.[Entries], LEN(A.[Entries]) - 5, 5), NULL)))) AS [X_TMSHT_TIMEIN]
FROM Employees  [B] 
inner JOIN [DTR Upload] [A] ON B.EmployeeNo = A.EmpID 
where B.LastName + ','+B.FirstName + ','+ B.MiddleName LIKE 'CRUZ,MA. KIMBERLY,CASTILLO%'
GROUP by B.LastName, B.FirstName, B.MiddleName,A.EmpID, A.[recordDate]
order by A.[recordDate] asc, B.LastName + ','+B.FirstName + ','+ B.MiddleName asc

这是我的结果

..X_TMSHT_EMPID.......||..X_TMSHT_APPLY..............||......X_TMSHT_TIMEIN........
001693............... ||    2019-05-03 00:00:00.000..||May  3 2019 12:00AM12:08

但我想要的是

..X_TMSHT_EMPID.......||..X_TMSHT_APPLY..............||......X_TMSHT_TIMEIN........
001693............... ||    2019-05-03 00:00:00.000..||05/03/2019  12:00:00 

0 个答案:

没有答案