T-SQL : How get only Time Part in DateTime value
Posted by
hungle
Labels:
SQL Server
DECLARE @CurrentDate datetime
SET @CurrentDate = '8/3/2006 4:09:00 PM'
SET @CompareDate = '8/3/2006 4:09:00 PM'
Get Time part as nvarchar or char :
Using :
select right(convert(nvarchar,@CurrentDate,120),9)
Or :
SELECT Convert(CHAR(24), @CurrentDate,108)
How to compare only time part in DateTime value , we use DatePart function :
DatePart(hour, @CurrentDate) >= DatePart(hour, @CompareDate) AND
DatePart(minute, @CurrentDate) >= DatePart(minute, @CompareDate) AND
DatePart(second, @CurrentDate) >= DatePart(second, @CompareDate) AND
blog comments powered by Disqus
Subscribe to:
Post Comments (Atom)