Author |
Topic  |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 06 May 2007 : 16:00:39
|
How to convert "1" to "01" in ASP ? |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 06 May 2007 : 17:07:59
|
Depends on what you mean exactly.
If you mean replace all the times the number "1" is in a string then it's like this:
replace(string, "1", "01")
Please be more specific though cause you might mean something totally different.
Greets, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 06 May 2007 : 17:11:30
|
I want to convert any number to 2 digits...
Like If I am extracting day as 9 , I want to convert it to 09 and if its 14 , then leave it as 14. |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 06 May 2007 : 17:19:24
|
Well, than the string you are pulling the data from should look something like:
StringName = Replace(StringName," 1 ", " 01 ") StringName = Replace(StringName," 2 ", " 02 ") StringName = Replace(StringName," 3 ", " 03 ") StringName = Replace(StringName," 4 ", " 04 ") StringName = Replace(StringName," 5 ", " 05 ") StringName = Replace(StringName," 6 ", " 06 ") StringName = Replace(StringName," 7 ", " 07 ") StringName = Replace(StringName," 8 ", " 08 ") StringName = Replace(StringName," 9 ", " 09 ")
I have left spaces, simply so 4 becomes 04 but 14 does not become 0104.
Greets, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 06 May 2007 : 17:23:59
|
Isnt there anything like Format ("1","00") to get 01 as result ?
I believe something like exists in VB... |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 06 May 2007 : 21:00:39
|
Maybe this will help? http://www.w3schools.com/vbscript/func_formatnumber.asp (you'll have to copy/past the link - the filter is removing the "vbscript" from the url....)
www.w3schools.com has a good reference page for VBScript - in particular a good function reference page. |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 07 May 2007 : 02:00:01
|
I checked the formtnumber function but didnt find any proper reference to convert any single digit to double digit |
Edited by - kolucoms6 on 07 May 2007 08:17:40 |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 07 May 2007 : 08:57:38
|
Then the only other options I can think of is to either use ILLHILL's code above or delve into regular expressions. Remember, VBScript is a sub-set of VB. It doesn't have all the functions that VB has. |
 |
|
cripto9t
Average Member
  
USA
881 Posts |
Posted - 07 May 2007 : 08:59:39
|
In "inc_func_common" used to format dates
function doublenum(fNum)
if fNum > 9 then
doublenum = fNum
else
doublenum = "0" & fNum
end if
end function
doublenum("10") = "10" doublenum("1") = "01" |
_-/Cripto9t\-_ |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 07 May 2007 : 09:05:59
|
Well there's that too.  |
 |
|
cripto9t
Average Member
  
USA
881 Posts |
Posted - 07 May 2007 : 09:18:15
|
 |
_-/Cripto9t\-_ |
 |
|
|
Topic  |
|