Modify db queries to resolve date related problems.