08-09-2023 06:44 PM - edited 08-09-2023 06:46 PM
Hi,
I have a Channel which contains Timestamps like every second:
then there are files that contain a picture and the name of the date the picture was taken:
1_20230324-121409.png
now I need to search through the timestamps to find the index closest to the day, the picture was taken.
In this example there are the values:
so the one in the middle would make it.
milli/microseconds aren't really important.
I just don't get an approach to this.
I'm able to create a datetime.datetime variable with the values out of the filename.
But afterwards I'm unable to seach for that date in the timestamp.
And I need the index of that timestamp, because I need a value of another channel with that index.
Does anyone have an approach for me?
Thanks in advance.
Solved! Go to Solution.
08-09-2023 09:29 PM
Not a diadem users, but if you subtract the search time from the array of times and take the absolute value, the smallest value will give you the index of the closest entry.
08-10-2023 02:43 AM
Hello,
you can find the index to the nearest value with the function PNo.
dim Index
Index = PNo("[1]/Time_Stamp", TTR("20230324-121409", "#yyyymmdd-hhnnss"))
LogFileWrite("Index: " & Index)
Regards
08-11-2023 04:57 PM
Thanks a lot, didn't know that PNo exists.
It's exactly what I was looking for.