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.
| Author |
Topic |
|
DHL
Starting Member
16 Posts |
Posted - 2008-05-27 : 07:29:47
|
| Hi,I have a column with records as follows:5 days7 days15 days20 days30 days60 days100 days120 daysHow can I only take out only the numeric part and make sure that this will be displayed as value as I have to make calculations using that value...Please helpThanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-27 : 07:33:49
|
| SELECT CAST(LEFT(value,CHARINDEX(' ',Value)-1) AS int) from table.If you're not sure whether you'll have space in all fields you need to check it using CASE WHEN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-27 : 07:45:33
|
| or you can even use PARSENAME functionSELECT COALESCE(PARSENAME(REPLACE(value,' ','.'),2),PARSENAME(REPLACE(value,' ','.'),1)) FROM Table |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-27 : 08:24:21
|
SELECT REPLACE(Col1, ' days', '')FROM Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
DHL
Starting Member
16 Posts |
Posted - 2008-05-27 : 09:20:53
|
| Visakh16, can you please clarify more in detail? The name of the column is 'payment_terms'Thanks! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-27 : 09:50:39
|
quote: Originally posted by DHL Visakh16, can you please clarify more in detail? The name of the column is 'payment_terms'Thanks!
SELECT COALESCE(PARSENAME(REPLACE(payment_terms,' ','.'),2),PARSENAME(REPLACE(payment_terms,' ','.'),1)) FROM TableDid you try the suggested methods?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|