Aggregating by month: "user-defined function raised exception"
What is the raw data stored in the Message.date column? Executing this code
```
    query = (dc.Message.select(dc.Message.date).limit(5))
    
    for q in query:
        print(q.date)
```
Gives me this response:

> 2016-08-31 15:39:00+02:00
> 2016-08-31 15:39:00+02:00
> 2016-08-31 15:25:00+02:00
> 2016-08-31 14:43:00+02:00
> 2016-08-31 14:31:00+02:00  The problem is that the datetime strings contain timezone information, which is not supported by these methods. If using SQLite, which does not contain a native datetime type, dates are stored in a text column in a format that ensures lexicographic ordering (so sorting and comparing datetimes works as you'd expect). You have the format correct (Y-m-d H:M:S) but the inclusion of the timezone will make ordering not work correctly (unless all values have the same timezone, which, if the case, means you can probably do without storing it anyways?). So to use the helper functions with SQLite, you'll want to store all datetimes as naive datetimes. If you use timezones, just convert to UTC before storing and convert back to local-time before using them in your application. @coleifer thanks, indeed it started to work after I removed timezone information.

There is still a little problem with `dc.Message.date.month` though. Ordering algorythm treats it as if it was string. So the order now looks like: "1", "10", "11", "12", "2" etc. Is there some quick workaround? You should be able to cast as an integer. [Sqlite Cast docs](https://sqlite.org/lang_expr.html#castexpr):

```python
MyModel.select().order_by(MyModel.timestamp.month.cast('INTEGER'))
```
Hi,
I'm trying to extract month from `date` column in my database. [Just as it's shown here.](http://docs.peewee-orm.com/en/latest/peewee/models.html#datetimefield-datefield-and-timefield)

Here is my code:
```
 query = (dc.Message.select(dc.Message.date.month.alias('month')).limit(5))
    
    for q in query:
        print(q.month)
```
And Message model:
```
class Message(BaseModel):
    text = CharField(null = True)
    created_by = ForeignKeyField(User)
    posted_in = ForeignKeyField(Chat)
    date = DateTimeField()
```

When I try to execute my code, I get this message in debug console:

> peewee.OperationalError: user-defined function raised exception

Do you have any ideas how to fix that?