I was thinking to use Tag.Timestamp property of a Boolean memory tag "NotScheduled" as starttime and now() as current time to get the difference.
This script appears to work half way, when I set another integer type memory tag "notScheduledTime" the tag value to 100 and run this, it changes to 0, I think the else logic part appears to work. But it was not updating the tag with duration minutes.
I would appreciate your help.
writeAsync is OK though, if you don't need to wait for it to write before continuing. Actually, writeBlocking is fine here too as it's writing to a memory tag