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/bedac435/attachment.htm
sum(duration+(6-mod(duration,6) for summary of seconds divisible by 6, /60 for minutes On Tue, 2006-11-14 at 00:07 +0530, Vicky wrote:> 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 ? > > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061113/befd1b44/attachment.htm
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@lists.digium.com [mailto:asterisk-users-bounces@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
On Tue, 14 Nov 2006, Vicky wrote:> 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 ?mysql> select floor(((3 + 5) / 6)) * 6; +--------------------------+ | floor(((3 + 5) / 6)) * 6 | +--------------------------+ | 6 | +--------------------------+ 1 row in set (0.00 sec) mysql> select floor(((13 + 5) / 6)) * 6; +---------------------------+ | floor(((13 + 5) / 6)) * 6 | +---------------------------+ | 18 | +---------------------------+ 1 row in set (0.00 sec) Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000