Server Administration

Problems filtering django datetime field by month and day returns Null

Yesterday,we ran into an issue that was due to a mysql bug on how we retrieve a queryset based on day and month .Example

idinvoice Namefrom_datedue_date
Invoicer Table

A queryset to check if there are any open invoices for current month would be

import datetime

On the surface,this should return the 3 invoices,oddly an empty queryset is returned.

An empty queryset inadvertently means.No invoice exists hence generate a new one.


The error was due to MySQL configuration missing timezone data as suggested here


 mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot --force  mysql -p
mysql import timezone

Despite the skipping error the queryset returned the three records instead of None

Leave a Reply

Your email address will not be published. Required fields are marked *