sql - Convert the datetime value to floor -
when go through our application's existing stored procedure, saw below code:
cast(floor(cast(@weekdate float)) datetime)
any 1 explain purpose behind code? @weekdate
datetime
field.
it truncates time datetime.
select dateandtime = getdate(), dateonly = cast(floor(cast(getdate() float)) datetime)
here way use on sql-server 2005:
dateadd(dd, datediff(dd,0, getdate()), 0)
sql-server 2008 introduced date
type, it's easier:
cast(@weekdate date)
Comments
Post a Comment