views:

24

answers:

2

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.

+1  A: 
declare @MyDate datetime
set @MyDate = '2010-07-06 14:46:37.577'

select DATEDIFF(MINUTE, @MyDate, CONVERT(varchar(10), @Mydate, 101)+' 17:00:00')
Joe Stefanelli
A: 
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)
bobs