[asterisk-users] Mysql 6 second rounding
Damon Estep
damon at suburbanbroadband.net
Mon Nov 13 12:50:27 MST 2006
Most usage charges are stored in various billing databases as per MINUTE
of use, not per 6 seconds of use.
6 second billing simply means that you bill in decimal fractions of a
minute, 66 seconds becomes 1.1 minutes.
1. Divide your billsec value by 60 and round to 1 decimal place. Add 0.5
to the result and then round if you want to round UP, that way 61
seconds is still 1.1 minutes.
2. Multiply the result times your per minute of use charge.
The reason 6 second billing is often used is because it translates
easily into decimal minutes :-)
Billminutes=round((billsec/60)+0.5),1)
Charge = round(billminutes*minutecharge,2)
________________________________
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Vicky
Sent: Monday, November 13, 2006 11:37 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] Mysql 6 second rounding
This is more of mysql question then asterisk :D . Most voip providers
use 6 second rounding for costing . My asterisk server stores call
cdr's in mysql properly with billsec field containing number of billed
seconds . I want to know some function to round this to 6 seconds ( or
any custom valud like 30 seconds ) ..Suppose if billsec field is 3
seconds then it should round to 6 seconds , if its 13 second then it
should round up to 18 seconds ( for 6sec pulse counting ) . What would
be mysql function to do this ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061113/b96dd173/attachment.htm
More information about the asterisk-users
mailing list