How to filter between dates from Pie Chart using Google API, PHP and MySQL

I Have created the script to generate the pie chart based on data from my database. It is displaying the work hours based on department just fine. However, I am unable to display by filtering between dates. Can I know what or how the code needs to be fixed to filter. In database I have already created timestamp named “CreatedOn”.

Show non-uniformly time-spaced samples from MySQL database on Google Line Chart by php query

I’m using a Line Chart of Google, I take data from a database of MySQL, to show points of some variables at different datetime. The sample time is 1 minute, but ocationally some points are loss (dont worry about the reason), so when I create de chart, the distance between two point is the same for 1 minute or 1 hour. I want to the horizontal space between samples be consistent with the time jump.