Is it possible to subtract a datestime ** ${starttime},${STRFTIME(${EPOCH},%Y-%m-%d_%H:%M:%S) ** with a variable in the same format and set the a new variable?
This would be much like using timediff in sql?
Ultimately I want to write the the new variable back to mysql.
I cant see how I can create the variable in the dialplan, in the function odbc or as a trigger in mysql.
If I could do the calculation in dialplan this would be the easiest way for me to manage the operation.
function ODBC looks to be too simple to be able to perform a timediff
and putting a trigger in before or after insert fails in dialplan
Any ideas on how to resolve this issue are gratefully received.
${EPOCH} returns a number. You should be able to do arithmetic on that.
I think it’s failing because of the date and time format I am using to match date time fields in mysql and thus it’s not a simple calculation, we are talking about subtracting time and dates to end up with HH:MM:SS
This is how I would like it to work
same => n,Set(starttime=${STRFTIME(${EPOCH},%Y-%m-%d_%H:%M:%S)})
The call happens for a duration of time
During the hangup this happens
same => n,Set(stoptime=${STRFTIME(${EPOCH},%Y-%m-%d_%H:%M:%S)})
same => n,set(duration=${${starttime} - ${stoptime}})
same => n,Set(log(${starttime},${stoptime},${duration})=1))
I’ve tested it and it doesn’t work. Is it possible to subtract date and time like this in the dialplan?
If not can it be done in the function_ODBC?
Why do triggers interfere with writesql commands in function_odbc?
Thanks
i know i am late but its always better to post answer if you know…
exten = _X.,n,Set(callstarttime=${STRFTIME(${EPOCH},%Y%m%d)}${STRFTIME(${EPOCH},%H%M%S)})
exten = _X.,n,Set(callendtime=${STRFTIME(${EPOCH},%Y%m%d)}${STRFTIME(${EPOCH},%H%M%S)})
exten =_X.,n,Set(diff1=$[${calltime1} -${calltime}])
exten=_X.,n,NoOp(diff1)
Cheers,
Pratap Thakur