Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date Time in SQL Server 2005

I have a datetime column in table that has time component.

Is there anyway I can set '2011-03-14 11:46:31' to '2011-03-14 00:00:00'?

like image 232
Rabin Avatar asked Sep 06 '26 11:09

Rabin


2 Answers

declare @date as datetime

set @date = getdate()

Select  Cast(Floor(Cast(@date as float)) as DateTime)
like image 137
codingbadger Avatar answered Sep 08 '26 00:09

codingbadger


Prior to 2k8 I always;

DATEADD(DAY, DATEDIFF(DAY, 0, datecol), 0) 
like image 26
Alex K. Avatar answered Sep 08 '26 00:09

Alex K.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!