Statistics widget: improve performance by better date handling

Up to now the dates queried and used by the statistics widget used to
Postgres' to_char() function to bring the date into a YYYYMMDD format.
Ignoring the time of the day is required to have meaningful statistics
per day. However, using Postgres' date_trunc() function is much faster
for the actual query. The transformation to the YYYYMMDD format is then
done in Python. This introduced a speed-up of about a factor of ten in
my test cases.