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
 SQL Server Development (2000)
 date

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-08-03 : 03:32:04
This sql produces the date as dd/mm/yy --> 01/01/2005
CONVERT(CHAR(10),p.StartDate,103) as 'StartDate',

BUT I would like to have 01/01/05 note 05 and not 2005
Thanks

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-08-03 : 03:39:39
use char(8) instead of char (10)

Duane.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-03 : 03:42:53
>>use char(8) instead of char (10)
That wont work

Where do you want to do this conversion?


Madhivanan

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

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-08-03 : 03:50:36
oops - my mistake,
This should work.

select REPLACE(convert(VARCHAR(10),p.StartDate, 103), '/' + CAST(YEAR(p.StartDate) / 100 AS VARCHAR(2)), '/')

Duane.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-08-03 : 04:17:48
use style 3 instead of 103 (103 includes century - yyyy format)

--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-03 : 04:21:31
Yes
But this kind of formating should be done in the presentation layer. If not supported there, then may be done in SQL quey

Madhivanan

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

- Advertisement -