Ability to query based on datetime

This patch enables querying based on datetime or time. It changes all datetimes to UTC prior to storing them in the database and prior to query substitution so that lexical comparison works as expected when comparing dates.