I have a date parameter so the date and time can always change.
For this example the datetime is '2010-07-06 14:46:37.577'
I need to see how much time is between this date paramter and the time of '17:00:00.000'
The time of 5PM will never change but as I said the date paramter can change.
declare @MyDate datetime
set @MyDate = '2010-07-06 14:46:37.577'
select DATEDIFF(MINUTE, @MyDate, CONVERT(varchar(10), @Mydate, 101)+' 17:00:00')
DECLARE @DateParameter datetime
DECLARE @DateTime5PM datetime
SET @DateParameter = '2010-07-06 14:46:37.577'
SET @DateTime5PM = CAST(CONVERT(varchar, @DateParameter, 101) + ' 17:00' AS datetime)
SELECT DATEDIFF (MI, @DateParameter, @DateTime5PM)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.