Properly handle dates within queries, fixes #27