Algorithm Request: Comparison against a range that wraps


Author Message
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 09:12am 25 Jun 2021      

Two ways I use.

As already alluded-to, convert the times to unix/epoch time then compare (later MMBasics have Epoch time built in) but here is a Function  I use all the time on smaller Mites

If Abs(UnixTime(d1$)-UnixTime(d2$))<=300 Then...


... or (as already alluded-to) use DateDiff  (which uses UnixTime at its core) and the time period of your choice to do the same comparison

If Abs(DateDiff("m",d1$,d2$))<=5 Then ...


Neither of the above methods are fazed by the wrap around from 23:59 to 00:00
Edited 2021-06-25 19:17 by CaptainBoing