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)
 make 20061 equal 200601

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2007-12-20 : 06:45:27
hi, how can I convert my bloody months into 01, 02,03 etc, instead of 1, 2 ,3 ?
I am having a nightmare when trying to sort..

thank you
jamie

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-20 : 06:47:18
UPDATE Table1
SET Col1 = LEFT(Col1, 4) + RIGHT('00' + SUBSTRING(Col1, 5, 8000), 2)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2007-12-20 : 06:57:36
cheers peso. that was doing my head in !
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-20 : 09:29:23
why are you concatenating year and month?

Madhivanan

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

jamie
Aged Yak Warrior

542 Posts

Posted - 2007-12-20 : 12:26:05
hi, so I can sort records into months and years...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-20 : 22:01:31
It seems that you have year and month in separate column. Why not use a single datatime column for this ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -