Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting Date in the Sql query

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2006-08-10 : 07:31:44

How to Extract only date from datetime in sql query?

Select CreatedDate from table

I get both date as well as time

But i want only date


How to do that?

Swati

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-10 : 07:38:40
[code]select dateadd(d,0,datediff(d,0,CreatedDate)) from table[/code]

or

[code]select convert(varchar(20),CreatedDate) from table[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2006-08-10 : 08:11:57
Try this

select convert(varchar,getdate(),101) - mm/dd/yyyy format
select convert(varchar,getdate(),103) - dd/mm/yyyy format
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-10 : 13:06:43
Select DateAdd(day,DateDiff(day,0,DateColumn),0) from yourTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -