Billsec from dialplan

Is it possible to get the CDR value billsec from dialplan?
The following snippet always returns zero:

exten => 1234,1,Dial(IAX2/1234,,g)
exten => 1234,n,Noop(Billsec: $[CDR(Billsec)])

Asterisk doesn’t keep a running total on the time. It simply sets the billsec variable to the difference in time between the call bein answered and the call hanging up.

You might want to try accessing it from the ‘h’ extension. The call would be technically hung up, so it may have the correct value then.

exten => 1234,1,Dial(IAX2/1234,g)

exten => h,1,Noop(Billsec: $[CDR(Billsec)])



I have always got 0 in Billsec but

exten => h,1,Noop(${DIALEDTIME})
exten => h,n,Noop(${ANSWEREDTIME})

Will give the total duration and the talktime.


If you are speaking about PSTN lines, through digium hardware, you should check first Reverce Polarity.