1

I entered data into a database, but the date is off, it is showing to the seconds.

How can i do a select statement to get this:

2010-02-18 07:45:00

To This:

2010-02-18

I am not the computer guy here....Thanks!

Bill
  • 33
  • 2

3 Answers3

3

SELECT Convert(varchar(10), DateColumn, 120) FROM TABLE

amit_g
  • 30,880
  • 8
  • 61
  • 118
  • For more functionality on the style (format of the date) Microsoft has a helpful page : http://msdn.microsoft.com/en-us/library/ms187928.aspx – Jacob Saylor Feb 25 '11 at 20:50
  • @Bill - if it works perfectly you should mark this answer as the correct/accepted answer so @amit_g gets the credit for helping you. – AMadmanTriumphs Feb 25 '11 at 20:53
  • Check out http://stackoverflow.com/questions/113045/how-to-return-the-date-part-only-from-a-sql-server-datetime-datatype for tips on faster solutions performance wize. – David Mårtensson Feb 25 '11 at 21:11
1

For any SQL Server version

select dateadd(d, datediff(d, 0, datecolumn), 0), ..
from ..

or for your 2008

select CAST(datecolumn as Date), ....
from ..
RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
0
DATE('2010-02-18 07:45:00');  

or variable in there

Or just change the column type definition from datetime to date

rayman86
  • 1,385
  • 10
  • 9