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 2005 Forums
 Transact-SQL (2005)
 Need Help

Author  Topic 

ashgupta
Starting Member

17 Posts

Posted - 2008-09-22 : 00:16:33
I need to format my column which is currently nvarchar(255) into a format dd/mm/yyyy.

I thought of using
SELECT CONVERT(NVARCHAR(255),[Start Date], 103)
from Tbl_test
It wouldnt work as the current column is already in NVARCHAR(255)

I Tried to conver the current column to datetime

SELECT CONVERT(datetime, [Start Date]) AS somthing
from tbl_test
where [start date] is not null

Error
>>Arithmetic overflow error converting expression to data type datetime.


Any help suggestions welcome !


what i need to get done is eg
[start date]
1/1/2008
5/10/2008

need to be
01/01/2008
05/10/2008

dd/mm/yyyy

ranganath
Posting Yak Master

209 Posts

Posted - 2008-09-22 : 01:03:06
Hi,

See Convert Functions in BOL
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-22 : 01:53:07
1 Always use proper DATETIME datatype to store dates
2 It is your front end application where you should do formation

Madhivanan

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

ashgupta
Starting Member

17 Posts

Posted - 2008-09-22 : 02:34:06
well there is no restriction where formation could be done
I can do directly on SQL server or front end
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-22 : 03:35:11
[code]SELECT CONVERT(CHAR(10), CONVERT(DATETIME, [Start Date], 103), 103)
FROM tbl_test[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

ashgupta
Starting Member

17 Posts

Posted - 2008-11-11 : 18:34:34
Tht works fine now thx
Go to Top of Page
   

- Advertisement -