datetime - What is the practical logic way to choose time intervals without leaving loose ends? -
this question has answer here:
- determine whether 2 date ranges overlap 30 answers
i have been trying figure out practical way select events of specific period of machine. have historical data of product arrival/process_start/process_finish times (datetime) machine , events (breakdown,repair,maintenance etc.) of machine event_start/event_type/event_finish times (datetime).
i want identify events happened @ machine product time arrives finishes process.
foreach(var product in productlist) var resultevents = events in eventlist (data.machine == product.machine) && (events.start<product.arrival && event.finish < product.finish)
this not giving me proper states, , gets confusing , ambigious outline options when machine may go down... should use process start or looking @ more && statements?
a quick feedback appreciated :) thanks!
you appear asking detecting overlapping ranges, - determining if time within 2 ranges intersect. test in duplicate post provided. using variable names, follows:
event.start <= product.finish && event.finish >= product.arrival
that assumes inclusive ranges. more commonly, use ranges inclusive @ start , exclusive @ end. known "half-open interval", denoted [start,end)
. prevents moment being in 2 different ranges. highly suggest use these. if do, test changes this:
event.start < product.finish && event.finish >= product.arrival
the change subtle, means won't include events start exactly @ product's finish time.
Comments
Post a Comment