Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format of Integers in returned field from Access DB

Status
Not open for further replies.

FurryGorilla

Technical User
Apr 11, 2001
76
GB
I have a query which returns a number of records in a table named oee based on the clock number and date that has been entered.

The table contains fields for activities which are 3 digit numbers. Unfortunately if the activity is 1 digit it returns it as 1 instead of 001. I've tried formatting the field in access and it is displayed correctly in the table but when I run the query from my asp page it still displays it as a single digit.

Any help would be greatly appreciated.

Thanks
Chris
 
Here some code

Code:
<script language=vbscript>
'var s = &quot;This is time!&quot;; 
'alert (s.search(&quot;time&quot;));
function zero(nr,digits)
 strNr=Cstr(nr)
 strTemp=&quot;&quot;
 for i=1 to digits-Len(strNr)
	 strTemp=strTemp+&quot;0&quot;
 next
 strTemp=strTemp+strNr
 zero=strTemp
end function

nr=13
MsgBox zero(nr,3)
</script>


Try it in browser but the function works in ASP to
The first param is the number you want to convert to (could be or number or string value)
The second is how many digits will have the return number and it's returned as a string value...

Hope this helps You... ________
George, M
 
It works perfectly after a slight bit of tweaking to remove the message box.

Thanks George :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top