Technical Article

Date Only

,

This is a follow-on to info's script to strip the time portion of a datetime or smalldatetime, leaving only the date.  I found info's script interesting!  When I had to do this I converted the date to varchar and back again instead of to float.  Seems to work fine for me.

create function TrimTime_dt (@Date as datetime)
returns datetime
as
begin
    return convert(datetime,(convert(varchar(10),@Date,101)))
end
go

select dbo.TrimTime_dt (getdate())

Read 33,116 times
(396 in last 30 days)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating