Coder Perfect

In SQL, how can I choose a date without the time?


When I use SQL to choose a date, it returns 2011-02-25 21:17:33.933. However, I simply require the Date portion, which is 2011-02-25. I’m not sure how I’m going to accomplish it.

Asked by Neeraj

Solution #1

For SQL Server 2008, follow these steps:

Convert(date, getdate())  

Please refer to

Answered by Prad9

Solution #2

I’m guessing he’s looking for a string.

select convert(varchar(10), '2011-02-25 21:17:33.933', 120)

The value 120 instructs the convert function that the input date should be in the format yyyy-mm-dd hh:mi:ss.

Answered by bernd_k

Solution #3

The quickest is datediff, for example.

select dateadd(d, datediff(d,0, [datecolumn]), 0), other..
from tbl

If you simply require the value, you can skip the dateadd, for example.

select ...
WHERE somedate <= datediff(d, 0, getdate())

where datediff(d, 0, getdate()) suffices to return today’s date without the time component.

Answered by RichardTheKiwi

Solution #4

CAST(GETDATE() as date) worked for me, and it was quite simple.

Answered by Anna-leny

Solution #5

             CAST( GETDATE() AS FLOAT ) 


Answered by Brandon Frohbieter

Post is based on