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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OnALearningCurveCommented:
Thanks for the points.

Glad I could help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.