DECLARE @StartTime [DateTime]
SET @StartTime = '01/01/2010 10:30:45'
DECLARE @EndTime [DateTime]
SET @EndTime = '01/01/2010 10:45:51'
SELECT
CASE WHEN DATEDIFF(second, @StartTime, @EndTime) / 3600 < 10 THEN '0' ELSE '' END
+ RTRIM(DATEDIFF(second, @StartTime, @EndTime) / 3600)
+ ':' + RIGHT('0'+RTRIM((DATEDIFF(second, @StartTime, @EndTime) % 3600) / 60),2)
+ ':' + RIGHT('0'+RTRIM((DATEDIFF(second, @StartTime, @EndTime) % 3600) % 60),2)
AS [HH:MM:SS]
it will give you the difference between two times then check
whether it is less then or Equals to 24 hours if it matches then
display that task