${ANSWEREDTIME} not showing value

i am making obd in inbound application…where i play a file to dialled number before patching the call using macro…but if dialled number answers the call and disconnect within play of file…${ANSWEREDTIME} not showing any value…how to capture the duration of succesfull obd in this case…only global variable working to store timestamp…which i dont want to use…

please enlighten me if something better could be done.

${ANSWEREDTIME} is set by asterisk on a particular channel and value of that variable will not be available to another channel if you use originate or callfile to generate outbound calls. Try to use AstDB to set a value of ${ANSWEREDTIME} in databse and read it from another channel.
However it is a bit difficult to suggest anything without looking at actual dialplan.

–Satish Barot

below is my dialplan:
if i disconnect inbound call earlier, while outdialled number is listening .asterisk disconnect both the calls…nd at hangup lablel ${ANSWEREDTIME get vanished…however i want to preserve that by some trick…as i am new to asterisk so i posted it here…kindly suggest how to do that…
exten = 233,1,NoOp(CALLERID :${CALLERID(num)})
exten = 233,n,Playback(/usr/ivrapps/prompts/welcome)
exten =233,n(dialno),Dial(DAHDI/g1/${num2call},${ringingtime},S(${maxduration})&g&M(screen^${File1}^${File2}))

exten = h,n,NoOp(DialedCallTime:${DIALEDTIME})
exten = h,n,NoOp(AnseredTime:${ANSWEREDTIME})

exten = h,1,Set(callendtime=${STRFTIME(${EPOCH},%Y-%m-%d)}%20${STRFTIME(${EPOCH},%H:%M:%S)})
exten = h,n,NoOp(dialed status at entered number is : ${DIALSTATUS})

[macro-screen]
;exten = s,1,Set(GLOBAL(connecttime)=${STRFTIME(${EPOCH},%Y-%m-%d)}%20${STRFTIME(${EPOCH},%H:%M:%S)})

;exten = s,1,Set(connecttime=${STRFTIME(${EPOCH},%Y-%m-%d)}%20${STRFTIME(${EPOCH},%H:%M:%S)})
;exten = s,1,Set(CDR(connecttime)=${STRFTIME(${EPOCH},%Y-%m-%d)}%20${STRFTIME(${EPOCH},%H:%M:%S)})
exten => s,n,Playback(${ARG1})
enten = s,n,Set(callstatus=0)
exten => s,n,Read(confirm,${ARG2},1,5)
exten => s,n(yes),MacroExit()

hi satish,

thank you, i have done the same using astdb variable.

Another option to use in your case is Shared variable.
Have a look at following link. It seems better to use this in your test scenario.
voip-info.org/wiki/view/Asterisk+func+shared

–Satish