-- Returns only the time portion of a DateTime, at the "base" date (1/1/1900)
CREATE function [dbo].[sudf_Common_TimeOnly]
(
@dtDateTime datetime
)
returns datetime
as
begin
-- Get the time only
return dateadd(day, -datediff(day, 0, @dtDateTime), @dtDateTime)
end
Please notice that the base date is January 1st 1900. Any dates/times prior to this day won't work,