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 2005 Forums
 Transact-SQL (2005)
 simple date Time question

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2010-09-22 : 10:25:00
Hi all,

i got this date in one table 8/29/2010 7:22:55 PM and want to convert it to 8/29/2010

How do i do that?

thanks a lot!

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-22 : 10:39:30
Do the formation at front end application
Otherwise use this

select dateadd(day,datediff(day,0,datecol),0) from table

Madhivanan

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

mike13
Posting Yak Master

219 Posts

Posted - 2010-09-22 : 11:21:43
quote:
Originally posted by madhivanan

Do the formation at front end application
Otherwise use this

select dateadd(day,datediff(day,0,datecol),0) from table

Madhivanan

Failing to plan is Planning to fail



Thanks that did the trick!
Go to Top of Page

glendcruz
Yak Posting Veteran

60 Posts

Posted - 2010-09-22 : 20:54:39
declare @date datetime
set @date = '8/29/2010 7:22:55 PM'
select convert(varchar,@date,101)
---------
08/29/2010

(1 row(s) affected)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-23 : 05:36:52
quote:
Originally posted by glendcruz

declare @date datetime
set @date = '8/29/2010 7:22:55 PM'
select convert(varchar,@date,101)
---------
08/29/2010

(1 row(s) affected)



Now the date values are actually varchars

Madhivanan

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

- Advertisement -