fixed date problem while writing to db