Fixed an error in date functions and added queries.