@ChuanYanF 

delegate table doesn't have active field so addActiveQuery() won't work.

I had removed it from my earlier script I shared

Did you check if that user has a valid delegate falling between those date/times.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader