I have a point pattern in Postgres where the pickup and dropoff times and locations of each taxi trip are recorded for several months. I need to count the number of taxi trips for a temporal window (e.g. between 00:00 and 03:00) for a given interval (e.g. between 5 March and 27 March). Therefore, for the given example, I need to calculate the total taxi trips occurred on 5 and 6 and 7, ..., and 27 March between 00:00 and 03:00.
The only function I found is 'date_trunc', but I don't really think that it is suitable, because the window size is already fixed.