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)
 From long date format to short date format

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-04-24 : 10:14:01
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

22864 Posts

Posted - 2006-04-24 : 10:27:00
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)

17689 Posts

Posted - 2006-04-24 : 21:09:09
[code]it is convert(varchar(10), StartTime, 105)[/code]
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
   

- Advertisement -