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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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)
 From long date format to short date format
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rookie_sql
Constraint Violating Yak Guru

Ireland
443 Posts

Posted - 04/24/2006 :  10:14:01  Show Profile  Reply with Quote
Hi i want to split my StartTime into a date format like 01-01-2006 it currently looks like "2006-04-20 00:00:00.000"
i tried to use the convert statement below but i can't recall number you use to only show the date part


Update Transfer
set [Date] = convert(varchar(10),StartTime, 102)

madhivanan
Premature Yak Congratulator

India
22864 Posts

Posted - 04/24/2006 :  10:27:00  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
You should format the date in your front end application. Dont worry how sql server stores it in table

Madhivanan

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

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 04/24/2006 :  21:09:09  Show Profile  Reply with Quote
it is convert(varchar(10), StartTime, 105)

Refer to SQL Server Books Online on CAST & CONVERT

quote:
Update Transfer
set [Date] = convert(varchar(10),StartTime, 102)

Why do you want to store the date in string format in your [Date] column ? Always store date & time in datetime data type or smalldatetime and use your Front End or Reporting tool to format the date.



KH


Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000