I have a nested list that contains date strings that I've split on the forward slash in the form of year/month/day/hour/minute, like so:
list = {{2016, 3, 3, 4, 25}, {2016, 3, 5, 3, 32}, {2016, 3, 8, 11, 54} .....}
I want to find the DateDifference between every one of these dates and {2016, 1, 1, 0, 0} (aka Jan 1st, 2016). I've tried using Map as well as attempted to pass the entire list as the second argument of DateDifference, but neither has worked; using Map only works if I don't provide any arguments to DateDifference,
DateDifference/@list
which will try to take the DateDifference between elements (not what I want), and I guess DateDifference is not listable. Is there a simple way to do this? I would prefer not to use DateObjects as they are very slow.
Table[QuantityMagnitude[DateDifference[{2016, 1, 1, 0, 0}, d]], {d, {{2016, 3, 3, 4, 25}, {2016, 3, 5, 3, 32}, {2016, 3, 8, 11, 54}}}]? (RemoveQuantityMagnitude[]if you want to keep the units.) – J. M.'s missing motivation Aug 09 '16 at 17:32Tableis listable though, it might work – Lame-Ov2.0 Aug 09 '16 at 17:37DateDifference[{2016, 1, 1, 0, 0}, #] & /@ {{2016, 3, 3, 4, 25}, {2016, 3, 5, 3, 32}, {2016, 3, 8, 11, 54}}works as expected – Jason B. Aug 09 '16 at 17:48Table[QuantityMagnitude[DateDifference[{2016, 1, 1, 0, 0}, d]], {d, myLongListOfDates}](and of course Jason's proposal is the alternative way to proceed). – J. M.'s missing motivation Aug 09 '16 at 18:00dsupposed to refer to, and how isddifferent from what I would input asmyLongListOfDates? This list will be fed into the next input as a pure function slot. I'll edit my OP to try and be a bit more clear – Lame-Ov2.0 Aug 09 '16 at 19:50din theTable[]code is an index, in much the same wayTable[d!, {d, 1, 5}]hasdas an index. Are you familiar with theforeachconstruction in other languages? The equivalent in Jason's proposal isQuantityMagnitude[DateDifference[{2016, 1, 1, 0, 0}, #]] & /@ myLongListOfDates. – J. M.'s missing motivation Aug 09 '16 at 19:52for. Thank you for clarifying. – Lame-Ov2.0 Aug 09 '16 at 20:05