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
 General SQL Server Forums
 New to SQL Server Programming
 convertion

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-03-05 : 02:40:34
can any one help how to convert the 20070701( varchar data type)
to 'JUL-07'

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-03-05 : 02:48:02
Use the front end you are displaying this in to do the conversion.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-05 : 03:21:41

1 Always use proper DATETIME datatype to store dates
2 Let your front end application do the formation

Madhivanan

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

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-05 : 03:51:20
[code]declare @a varchar(10)

set @a = '20070701'

select left(datename(month, @a),3) + '-' + right(cast(year(@a) as varchar(4)),2)[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-05 : 03:54:40
Impli(simply)cit convertion


declare @a varchar(10)

set @a = '20070701'

select left(datename(month, @a),3) + '-' + right(year(@a),2)


Madhivanan

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

- Advertisement -