-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,505
  • 10
  • 64
  • 103

3 Answers3

1
SELECT  CAST(enteredDateTime AS DATE)
FROM    mytable
Quassnoi
  • 413,100
  • 91
  • 616
  • 614
  • @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,346
  • 14
  • 60
  • 99
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,418
  • 18
  • 79
  • 130