Sums in asp with SQL data

Hi,

i have a weekly_rate (i.e. £75)for a rental in a table and i want to select the weekly rate from the database, display it on the asp page (which i can do) but then multiply the weekly rate by 52 then divide it by 12 to get a monthly rate (in this case £325), which will show in a gridview.

Please help Thanks
sweeting89Asked:
Who is Participating?
 
OnALearningCurveCommented:
Fairly,

Assuming you have set up a connection to your database (I'll call this "SQL_CONN" in this instance) you would use something like the code attached.

Hope this helps,

Mark.
<%

SQL_String = "SELECT weekly_rate FROM your_table WHERE ..."

set rs = SQL_CONN.execute(SQL_string)

do until rs.eof
     'Add any html or formatting here
     response.write((rs("weekly_rate")*52)/12)
     'Add any html or formatting here
     rs.movenext
loop

rs.close

%>

Open in new window

0
 
OnALearningCurveCommented:
Hi sweeting89,

Assuming you have created a result set from your SQL query (lets call it rs)

and assuming the filed in your result set is called "weekly_rate" you would simple use the following

response.write((rs("weekly_rate")*52)/12)

Hope this helps,

Mark.
0
 
sweeting89Author Commented:
No, i haven't created a results set. will this be easy to set up?

Thanks
0
 
OnALearningCurveCommented:
Thanks for the points.

Glad I could help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.