Same issue as well with historical data. It is super shaky. not sure yet how to solve it, but Maybe writng a Script might help, instead using the formula.
There is as well sometimes the same issues using historical date (and time) when I changed the date to one day earlier it did work suddenly.