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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 From long date format to short date format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

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)

Premature Yak Congratulator

22847 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


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

In (Som, Ni, Yak)

17684 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

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.


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.05 seconds. Powered By: Snitz Forums 2000