Author |
Topic |
Looper
Yak Posting Veteran
68 Posts |
Posted - 2011-04-08 : 04:01:22
|
What is the best way to substring an integer valuee.g a value of 2010, I want it to be 10 in my variable? |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-08 : 04:10:48
|
For example:select right(str(2010),2) No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-08 : 04:11:16
|
1) SELECT RIGHT(Col1, 2) FROM dbo.Table12) SELECT Col2 % 100 FROM dbo.Table1 N 56°04'39.26"E 12°55'05.63" |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2011-04-08 : 07:08:42
|
So simple...SELECT 2010 - 2000 ______________________ |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-04-08 : 07:11:00
|
quote: Originally posted by ms65g So simple...SELECT 2010 - 2000 ______________________
And if there are different values in column instead of this hard coded value 2010 then ? ;). I think PESO answer is perfect--------------------------http://connectsql.blogspot.com/ |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2011-04-08 : 07:13:48
|
quote: Originally posted by lionofdezert
quote: Originally posted by ms65g So simple...SELECT 2010 - 2000 ______________________
And if there are different values in column instead of this hard coded value 2010 then ? ;). I think PESO answer is perfect--------------------------http://connectsql.blogspot.com/
Are you OP?______________________ |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-08 : 08:10:52
|
quote: Originally posted by ms65g So simple...SELECT 2010 - 2000 ______________________
If it is simple like that then it is also simple like this:SELECT 10 No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2011-04-08 : 08:18:56
|
quote: Originally posted by webfred
quote: Originally posted by ms65g So simple...SELECT 2010 - 2000 ______________________
If it is simple like that then it is also simple like this:SELECT 10 No, you're never too old to Yak'n'Roll if you're too young to die.
The problem is very simple so the solution is simple to.SELECT 10 is constant and static by following query is not joke:SELECT column - 2000 FROM TableName;______________________ |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-04-08 : 16:47:15
|
All other, what about value 1998?I think OP need that to result in 98, not -2. N 56°04'39.26"E 12°55'05.63" |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
|
|