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?
Asked
Active
Viewed 440 times
-3

harriyott
- 10,505
- 10
- 64
- 103

user3819358
- 1
- 1
-
6Look at you profile.. *"I have 3 year experience in .Net technology's and Ms Sql Server. "* I don't believe you !!! – Jul 09 '14 at 10:09
-
Change the datatype to `date`? – podiluska Jul 09 '14 at 10:34
-
1@Popeyethesailorman: Seems your comment made his profile changed :) – huMpty duMpty Jul 09 '14 at 12:46
3 Answers
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
-
-
1Have you read the question. OP says *"How do I get only the date instead of the date and time"* !! – huMpty duMpty Jul 09 '14 at 10:05
-