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) 

demo

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

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -