I am interesting to calculate the time between a first event and last event.
I calculate this in following way: The data looks as:
datesListEx = {"2014-12-08", "2014-01-14", "2014-05-30", "2014-11-13",
"2014-03-30", "2014-09-28", "2014-03-05", "2014-07-28",
"2014-03-05", "2014-11-13", "2014-02-12", "2013-11-27",
"2013-12-08", "2014-01-04", "2014-07-07", "2014-07-07",
"2014-03-30", "2014-11-13", "2014-02-21", "2014-04-23",
"2013-11-11", "2014-04-06", "2014-02-12", "2014-01-04",
"2014-08-25", "2014-10-07", "2013-11-19", "2013-11-19",
"2014-02-18", "2014-10-07", "2014-01-14", "2013-11-04",
"2014-03-05", "2014-02-12", "2014-05-30", "2014-12-08",
"2014-02-02", "2014-07-07", "2014-06-12"};
I sorted the data
datesListExSort = Sort@datesListEx;
And subtraction
DateDifference[First[datesListExSort], Last[datesListExSort]]
I repeat the action thousands of times (with different data), the subtraction between dates that takes a lot of time. Is there a way to speed up this action?
AbsoluteTime /@ datesListEx
and do computations and finally convert back withDateString[#, {"Year", "-", "Month", "-", "Day"}] &
. (Documentation says "AbsoluteTime[] gives the total number of seconds since the beginning of January 1, 1900, in your time zone.") $\endgroup$ – Henrik Schumacher May 12 '18 at 14:21