added getbyday query logic