Fix error with long aggregates (week/month)

Hi,

I think I found at least one problem with large zoom out, if the data is not stored in timestamp order (by vzcompress or manual load). Please verify the change.