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
 Transact-SQL (2000)
 Convert DateTime to Date

Author  Topic 

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2006-01-10 : 14:59:28
Having a brain cramp here. How do I convert a DateTime column to Date?

i.e. get "01/10/2006" from "01/10/2006 14:00:00PM"

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-10 : 15:28:47
Refer BOL --> Convert
print convert(varchar(10),getdate(),101)

print convert(varchar(10),DateTimeCol,101)
Go to Top of Page

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2006-01-10 : 15:42:06
DOH! Thanks.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-10 : 22:33:31
>> get "01/10/2006" from "01/10/2006 14:00:00PM"
if is just formating and displaying, do this in your front end application.

If you want to remove the time component for comparision, use this
select dateadd(day, 0, datediff(day, 0, getdate()))

-----------------
'KH'

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-12 : 07:55:25
>>.e. get "01/10/2006" from "01/10/2006 14:00:00PM"

Where do you want to show the converted dates?
If you use Front End application, use format function there

>>select dateadd(day, 0, datediff(day, 0, getdate()))

Also you can use

select dateadd(day, datediff(day, 0, getdate()),0)




Madhivanan

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

- Advertisement -