Fix database unique date problem