There may be quicker functions or SQL functions that would do the truck but here is code that demonstrates the conversion of dates and times from display formats to internal cache formats as well as the use of the various datetime functions, as well as operators such as integer divide "\" and modulo "#"
AddTime(datetime, addtime)
I '$length($get(datetime)) quit "" ; no datetime passed in
I '$length($get(addtime)) quit datetime ; no time added, return original value
; assume datetime is passed in ODBC format as is addtime
; e.g. "2013-10-06 14:35:23" and "08:24:45"
Set datetime = $zdth(datetime,3),date=$piece(datetime,",",1),time=$piece(datetime,",",2)+$zth(addtime,3)
If time>86400 set date=date+(time\86400),time=time#86400
; return ODBC datetime
Quit $zdt(date_","_time,3)
Nigel Timothy Bloom-Salm