Hi everyone, I need to do calculations on millions of timestamps, such as
t0 = "2011-01-11 11:30:01.321"
If I want to subtract 12 hours from the timestamp and convert the result to a list of date items, I could use DatePlus and DateList like this
DateList[DatePlus[t0, {-12, "Hour"}]]
and it takes {0.003359,{2011,1,10,23,30,1.}} on my MacBook Pro. But it is apparently a lot faster subtracting the 12 hours this way
DateList[DateList[t0] + {0, 0, 0, -12, 0, 0}]
taking only {0.000801,{2011,1,10,23,30,1.321}}, where the outer DateList conveniently adjusts the day so that the hours position shows a positive integer. The second way also keeps the fractions of a second (1.321) where the first way drops them.
I'm leaning towards doing it the second way, and am curious to know whether anyone see a downside.