Time Difference

Hello everyone

Could anyone please tell me how do I find the TIME difference between any given number of times based on certain condition?

e-g

Find the "later" time between the given DateTimes below e-g it would be 2010-10-22 08:10:46.053 in this case because it is the latest time out of the four given date times.

Find the "earlier" time between the given DateTimes below e-g it would be 2010-10-22 06:45:46.053 in this case because it is the earliest time out of the four given date times.
1
2
3
4
5

2010-10-22 07:05:41.053
2010-10-22 08:10:46.053
2010-10-22 07:05:46.053
2010-10-22 06:45:46.053


Then find the time difference between the two times i-e between the earliest and the latest time. Date would always remain the same. Difference occurs only in the TIME part of a given DateTime.

The pairs/groups of DateTimes are stored in a vector.

Thanks
It depends on how the DateTimes are stored. Are these stored as time_t, struct tm, character strings?
Hello kooth.

They are stored as time_t and sorted from latest to earliest time. Is retrieving the first and last elements of this sorted vector through front() and back() a good approach? and then finding the difference between those two times.

Thanks
Sounds good to me!
ok :-)
Topic archived. No new replies allowed.