SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Convert DateTime to Date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 01/10/2006 :  14:59:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Sri Lanka
1378 Posts

Posted - 01/10/2006 :  15:28:47  Show Profile  Reply with Quote
Refer BOL --> Convert
print convert(varchar(10),getdate(),101)

print convert(varchar(10),DateTimeCol,101)

Edited by - Srinika on 01/10/2006 15:34:26
Go to Top of Page

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 01/10/2006 :  15:42:06  Show Profile  Reply with Quote
DOH! Thanks.
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17638 Posts

Posted - 01/10/2006 :  22:33:31  Show Profile  Reply with Quote
>> 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

India
22761 Posts

Posted - 01/12/2006 :  07:55:25  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
>>.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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000