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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -