some utility functions for querying date and bucketizing