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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatnumber ASP columns from SQL

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I,m trying to format a column from a SQL query passed to an ASP page. The result is now showed like this
90
90,5
90.66

I would like to have a format number like this
90.00
90.55
90.66

I used this code before a switch to SQL

<td>
<div align=&quot;center&quot;><font size=&quot;1&quot;><%=FormatNumber(Server.HTMLEncode(rs.Fields(&quot;TTmoyenne&quot;).Value), 2) %></font></div>
</td>

But with SQL and FP/ASP that create a &quot;bot&quot; and 1 don't how to pass a formatnumber criteria to get the right decimal place.

_____

Here's the new code in the ASP page, generated by FrontPage insert database wizard:

<!--webbot bot=&quot;DatabaseRegionStart&quot; startspan
s-columnnames=&quot;Pilote,Moyenne,Nombre de course aujourdhui,Dernière mise à jour&quot;
s-columntypes=&quot;202,5,3,135&quot; s-dataconnection=&quot;SRP&quot;
b-tableformat=&quot;TRUE&quot; b-menuformat=&quot;FALSE&quot; s-menuchoice=&quot;Pilote&quot;
s-menuvalue=&quot;Pilote&quot; b-tableborder=&quot;TRUE&quot; b-tableexpand=&quot;FALSE&quot;
b-tableheader=&quot;TRUE&quot; b-listlabels=&quot;TRUE&quot; b-listseparator=&quot;TRUE&quot;
i-ListFormat=&quot;0&quot; b-makeform=&quot;TRUE&quot;
s-recordsource=&quot;web tt moyenne hier&quot;
s-displaycolumns=&quot;Pilote,Moyenne,Nombre de course aujourdhui&quot;
s-criteria s-order
s-sql=&quot;SELECT * FROM &quot;web tt moyenne hier&quot;&quot;
b-procedure=&quot;FALSE&quot; clientside SuggestedExt=&quot;asp&quot;
s-DefaultFields
s-NoRecordsFound=&quot;Aucun enregistrement renvoyé.&quot;
i-MaxRecords=&quot;256&quot; i-GroupSize=&quot;0&quot; BOTID=&quot;0&quot;
u-dblib=&quot;../../../../../../_fpclass/fpdblib.inc&quot;
u-dbrgn1=&quot;../../../../../../_fpclass/fpdbrgn1.inc&quot;
u-dbrgn2=&quot;../../../../../../_fpclass/fpdbrgn2.inc&quot; tag=&quot;TBODY&quot;
local_preview=&quot;&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;L'aperçu des requêtes de résultats de base de données est disponible uniquement si cette page est accédée depuis un serveur Web par un navigateur Web. La ligne suivante du tableau s'affiche pour chaque enregistrement renvoyé par la requête.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&quot;
preview=&quot;&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;Début d'une requête de résultats de base de données. La page doit être accédée depuis un serveur Web par un navigateur Web pour s'afficher correctement&nbsp;; le site Web en cours est placé sur votre disque local ou sur le réseau.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&quot; b-WasTableFormat=&quot;TRUE&quot; --><!--#include file=&quot;../../../../../../_fpclass/fpdblib.inc&quot;-->
<%
fp_sQry=&quot;SELECT * FROM &quot;&quot;web tt moyenne hier&quot;&quot;&quot;
fp_sDefault=&quot;&quot;
fp_sNoRecords=&quot;<tr><td colspan=3 align=left width=&quot;&quot;100%&quot;&quot;>Aucun enregistrement renvoyé.</td></tr>&quot;
fp_sDataConn=&quot;SRP&quot;
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=&quot;Pilote&quot;
fp_sMenuValue=&quot;Pilote&quot;
fp_iDisplayCols=3
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file=&quot;../../../../../../_fpclass/fpdbrgn1.inc&quot;-->
<!--webbot bot=&quot;DatabaseRegionStart&quot; i-CheckSum=&quot;35441&quot; endspan -->




AND HERE'S THE LINE WHERE THIS RESULT COME FROM:


<td align=&quot;center&quot;><font color=&quot;#FFFFFF&quot; size=&quot;1&quot;><!--webbot
bot=&quot;DatabaseResultColumn&quot; startspan
s-columnnames=&quot;Pilote,Moyenne,Nombre de course aujourdhui,Dernière mise à jour&quot;
s-column=&quot;moyenne&quot; b-tableformat=&quot;TRUE&quot; b-hasHTML=&quot;FALSE&quot;
clientside
local_preview=&quot;<font size=&quot;-1&quot;>&lt;&lt;</font>moyenne<font size=&quot;-1&quot;>&gt;&gt;</font>&quot;
preview=&quot;<font size=&quot;-1&quot;>&lt;&lt;</font>#ERREUR#<font size=&quot;-1&quot;>&gt;&gt;</font>&quot; ,2 ,2 --><%=FP_FieldVal(fp_rs,&quot;moyenne&quot;)%><!--webbot
bot=&quot;DatabaseResultColumn&quot; i-CheckSum=&quot;16094&quot; endspan -->
</font></td>


Any help ???

Regard

Louis.
 
If you want a number rounded off to a certain decimal place, then you can use the round() function like so:

dim someNumber
someNumber = 68.798
response.write(round(someNumber, 2))

output:
68.80

 
You could also use link9's suggestion in conjunction with the cDbl function like so:

div align=&quot;center&quot;><font size=&quot;1&quot;><%=round(cDbl(rs.Fields(&quot;TTmoyenne&quot;).Value), 2) %></font></div>


Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top