# Scheduled Queries in Google BigQuery
A scheduled query lets you run a SQL statement at a set time interval. One great advantage of this is 'materialise' views or slow running SQL. For instance, Google can run the SQL for you once early in the morning, so when your users need to access it multiple times during the day, all the joins, logic and aggregations are done and the data is ready for them.
# Backfilling data
There is the option to 'backfill' data from scheduled queries. For instance, if I have a set of historical data I need to load I can schedule it automatically with this.
When I first needed this, my source data was partitioned by day, and I only needed to get the latest day each time. I used current_date() in the SQL, thinking that the backfill would update this to the time periods I requested through the UI. However, after loading a year's data I realised it was just appending the latest days data over and over again!
So instead you have to use @run_date instead of current_date() in your SQL to specify a single or set of days. Unfortunately you cannot just run the SQL with @run_date in the query composer, but it does work when called by the query scheduler.
Also note, that when you are specifying the date range to run the backfill, there is a max of 180 days at a time. Also, when you give the lower date it IS inclusive, but the upper date IS NOT inclusive. So, specifying a backfill from 'Jan 1st' to 'Jan 4th' loads (Jan 1, Jan 2, Jan 3) only.