Ravi, yes exactly what I was thinking too, that I would have to account for the varying number of days in different months which could be cumbersome.
Henrique, I do have time data generated and this is an interesting alternative. One I think that would be slower but I would like to test it. I get your concept however I'm stuck on the 'CASE WHEN A=0' portion. I'm not sure what you intended me to do there.
-Patrick