-3

I have a table in which there is one column, EnteredDateTime. This column contains the date and time. How do I get only the date instead of the date and time?

harriyott
  • 10,335
  • 10
  • 62
  • 100

3 Answers3

1
SELECT  CAST(enteredDateTime AS DATE)
FROM    mytable
Quassnoi
  • 398,504
  • 89
  • 603
  • 604
  • @user3819358: You can accept the answer if it works, by clicking in the check mark next to the answer!! –  Jul 16 '14 at 16:17
0
Select Convert(Date, EnteredDateTime) as EnteredDateTime
From TableName

Have a look at CAST and CONVERT

huMpty duMpty
  • 14,061
  • 13
  • 55
  • 93
0

Try this:

SELECT  CAST(yourDateTimeColumn AS DATE) from tableName

for example

SELECT  CAST(GETDATE() AS DATE)

gives me

2014-07-09

Refer this: http://www.w3schools.com/sql/sql_dates.asp

Ajay
  • 6,396
  • 17
  • 68
  • 126