Change date format and small fixes

* New date format for all input: YYYY-MM-DD, to make it consistent with the output format
* Fix date filtering in /query route
* Prevent some crashes when called with bad input