06-21-2025 04:39 AM
Hi all,
I'm working on where I have a 2D array of timestamps.
One 2D Array represents Total Working Hours
The other 2D Array represents Break Times
I want to convert this data into a cluster that includes:
1.Start time
2.End time
3.A flag (0 or 1) indicating whether the entry is break time (1) or working time (0)
However, I'm facing an issue where overlapping data is being generated in my current logic, especially when break times and work times cross over or overlap.
My goal is to have a clean list of non-overlapping time intervals with the correct flag set.
Can someone suggest the right way to structure this logic or share a method to handle overlaps when building the cluster?
Any help or sample VI would be much appreciated!
Thanks in advance!
Solved! Go to Solution.
06-21-2025 09:44 AM - edited 06-21-2025 10:14 AM
OK, let's define the problem a little better.
Also: do you know that index array is resizable and if you want elements in order, you don't need to wire indices?
06-21-2025 10:58 AM
Thanks for your reply! Here are the clarifications:
1. Labels of input arrays:
The first 2D array column is Scheduled Work Time – each row has a start and end timestamp.
The second 2D array column is Break Time – again, each row has a start and end timestamp.
2. Significance of columns:
Yes, both arrays represent start and end times (i.e., time intervals).
3. If intervals overlap, what should take precedence?
Breaks take precedence — if a break overlaps with work time, that portion should be flagged as a break (flag = 1).
4. Time alignment (quantization):
No, the times are not always quantized to 60 minutes or 0.5 hours. It's just a simplified example. Actual timestamps may have arbitrary minute-level resolution.
5. Are scheduled hours always continuous?
No, there might be gaps between scheduled work periods.
6. Does the day always end in a non-break?
Not necessarily — the day could end during a break.
7. Are breaks always 1 hour?
Not always. Break durations can vary.
8. About Index Array:
Thanks for the tip — yes, I'm aware Index Array is resizable, but I’ll double-check if I’m using it efficiently.
06-21-2025 11:25 AM - edited 06-21-2025 11:28 AM
@Tusharvp4 wrote:
4. Time alignment (quantization):
No, the times are not always quantized to 60 minutes or 0.5 hours. It's just a simplified example. Actual timestamps may have arbitrary minute-level resolution.
I was curious why you would show millisecond resolution in your timestamps. So the times are quantized to whole minutes?
@Tusharvp4 wrote:
5. Are scheduled hours always continuous?
No, there might be gaps between scheduled work periods.
OK that complicates things. So you have three states (scheduled, break off), but don't want to show the off intervals. Can there bet gaps (1) between two work periods, (2) within a break period, (3) immediately before or after a break? (4)....
@Tusharvp4 wrote:
8. About Index Array:
Thanks for the tip — yes, I'm aware Index Array is resizable, but I’ll double-check if I’m using it efficiently.
Compare the picture!
06-21-2025 11:34 AM
Thanks again for your follow-up! Let me clarify a few things:
Question - Millisecond resolution in timestamps — are they quantized to whole minutes?
You're right to notice that. In reality, the timestamps are only relevant to the minute level — so quantized to whole minutes. Millisecond precision isn't needed and was just a byproduct of how the timestamps were generated or displayed. I’ll clean that up for clarity.
Question : Gaps in scheduled time mean three states (work, break, off)?
Correct — in theory, we could say there are three logical states:
1. Scheduled Work (flag = 0)
2. Break (flag = 1)
3. Off (no schedule or break)
But for now, I want to ignore the "off" state and just build a clean list of non-overlapping work and break intervals, flagged accordingly.
Question: Incorrect photo for Index Array usage
Yes — you're absolutely right, I posted the wrong image. I will update the VI screenshot with the correct version showing the resizable Index Array so it’s more readable and aligned with best practices.
Thanks again for the sharp observations.
06-21-2025 11:44 AM
Timestamp Format:
All timestamps are in the format:
yyyy-mm-dd hh:mm:ss.000
However, the precision needed is only to the minute — so seconds and milliseconds can be ignored for logic purposes. The .000 is just default formatting.
Main Objective:
My primary goal is to build a cluster (or array of clusters) with the following structure:
Flag → 0 for Work, 1 for Break
Start Time
End Time
I want to generate a clean, non-overlapping list of time intervals from the input arrays (scheduled work and break times), with each interval correctly flagged.
Just for clarification..I am not currently concerned with visualizing or processing "off" times — only interested in work and break intervals.
Appreciate your support and suggestions.
06-21-2025 12:06 PM
@Tusharvp4 wrote:
Just for clarification..I am not currently concerned with visualizing or processing "off" times — only interested in work and break intervals.
But they do overlap, because the end time of one state is the same as the start time of the other state.
06-21-2025 12:15 PM
Yes, you are correct — in many cases, the end time of one interval is exactly equal to the start time of the next (e.g., work ends at 12:00 and break starts at 12:00). I don’t consider that an “overlap” — just a clean hand-off between intervals.
To clarify:
This is expected behavior, and I treat such adjacent intervals as non-overlapping.
The logic should simply preserve these as separate clusters, like:
As for Examples
Start: 08:00, End: ,09:00, Flag: 0 (work)
Start: 09:00, End: ,10:00, Flag: 0 (work)
.
.
.
Start: 12:00, End: 13:00, Flag: 1 (break)
06-21-2025 02:22 PM
Here are a few suggestions:
Bob Schor
06-21-2025 02:32 PM
See if this can give you some ideas:
Basically we iterate over all minutes to find state changes. We must assume that each of the input arrays is clean (i.e. sorted without overlapping ranges between rows. (Rows can overlap between the two input arrays, of course!)
I am sure things can be simplified more. There could also be bugs, of course.