Not sure if this is what you need, but this is example how to get workshift information by ID and use it to calculate duration between two dates
send_wait(0,top_object(),"call_attr","wrkshft","sync_fetch","DYNAMIC",format("persistent_id = 'wrkshft:4600'"),-1,0);
if (msg_error()) {
logf(ERROR, "Update object macro error: %s, Incident %d", msg[0], ref_num);
}
int wrkfound;
object wrkList,wrkPointer;
wrkList = msg[0];
wrkfound = msg[1];
if (wrkfound > 0)
{
send_wait(0, wrkList, "dob_by_index", "DEFAULT",0, 0);
if (msg_error())
{
logf(ERROR, format("AHDConnect:dob_by_index %s, Incident %d", msg[0], ref_num));
return (-4);
}
wrkPointer=msg[0];
}
string business_hours;
business_hours = wrkPointer.sched;
newDuration = workshift_abs2work(business_hours, open_date, last_mod_dt);