See if datetime is within range
Show older comments
I have two datasets of datetime and numerical values where the data was collected at incongruous times. For example:
Dataset 1:
'3/25/2024 15:01:15' 1
'3/25/2024 15:01:31' 2
'3/25/2024 15:01:47' 0
'3/25/2024 15:02:03' 0
'3/25/2024 15:02:19' 0
'3/25/2024 15:02:35' 0
'3/25/2024 15:02:51' 1
'3/25/2024 15:03:07' 2
Dataset 2:
'3/25/2024 15:01:10' 10
'3/25/2024 15:01:26' 20
'3/25/2024 15:01:42' 30
'3/25/2024 15:01:58' 40
'3/25/2024 15:02:14' 50
'3/25/2024 15:02:30' 60
'3/25/2024 15:02:46' 70
I'd like to delete rows from dataset 1 and 2 that are in the same range of datetime. In this example, I'd like to delete the rows from dataset 1:
'3/25/2024 15:01:47' 0
'3/25/2024 15:02:03' 0
'3/25/2024 15:02:19' 0
'3/25/2024 15:02:35' 0
and therefore delete rows with the datetime in the same range from dataset 2:
'3/25/2024 15:01:58' 40
'3/25/2024 15:02:14' 50
'3/25/2024 15:02:30' 60
2 Comments
Voss
on 25 Mar 2024
You want to delete rows 3, 4, 5, and 6 from dataset 1, and also delete any rows from dataset 2 where the datetimes are within the range of the rows deleted from dataset 1. Is that right?
If so, why would rows 2 and 3 be deleted from dataset 2? Those are not in range (they are both before the first deleted dataset 1 datetime, '3/25/2024 15:01:47'). Only rows 4, 5, and 6 in dataset 2 are within the range '3/25/2024 15:01:47' to '3/25/2024 15:02:35'.
Joy
on 25 Mar 2024
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!