>> Is there an easy way to compare TIME SQL2K?You want to compare time only or Date & time ?>> We can use CONVERT function but that will be bit complicated.What is the complication ? If your column is a datetime and you need to compare TIME only (without DATE), your query might suffer from performance issue.Here illustrate 2 method to extract the TIME from the datetime.declare @time1 datetime, @time2 datetimeselect @time1 = '2006-01-10 12:34:56', @time2 = '2006-01-12 01:23:45'-- This convert both @time1 & @time2 into same date (1900-01-01) such that you can compare the time. -- Note : Resuls is a datetimeselect tm1 = dateadd(day, datediff(day, 0, @time1) * -1, @time1), -- This uses convert function + substring to extract the time. -- Note : Result will be a varchartm2 = dateadd(day, datediff(day, 0, @time2) * -1, @time2)select tm1 = substring(convert(varchar(25), @time1, 121), 12, 12), tm2 = substring(convert(varchar(25), @time2, 121), 12, 12)
-----------------'KH'