2013-10-22 290 views
0

- Datetime format = '2013-10-21 12:12:12.000' --Obviously可怜的语法,但你可以看到我试着做SQL Server 2008中的日期时间转换成秒/毫秒

select personnum, convert(decimal, shiftEndDate, 4)-convert(decimal, ShiftStartDate, 4) as ShiftInSeconds 
from dbo.Time 
where shiftStartDate between '2013-10-14 00:00:00.000' and '2013-10-20 23:59:59.000' 

回答

0

可以使用DATEFROMPARTSshiftEndDate创建date类型,然后投你条件字符串日期/日期时间(SQL服务器应该自动执行此操作,如果没有 - 使用CAST/CONVERT