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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -