Add query option for last x days

Added an option in the SQL query to only collect the records from the last x days, determined by a new parameter called "period" in the settings file. It supports fractions of a day, i.e. if we want the last 12 hours of records then "period = 0.5"