postgresql - declaring variables to be used for start_time - end_time range
This is what my final solution looked like, and worked for me.
DO $$
DECLARE 

--Specify start date - end date in YYYY-MM-DD format.
start_date timestamp := '2020-10-1';
end_date timestamp := '2020-10-5';


BEGIN
    CREATE TEMP TABLE temp_output ON COMMIT DROP AS
    select distinct on (account.id, menu.name, kitchen_item.name)
    account.id as &quot;Account ID&quot;,
    account.firstname as &quot;Seller First Name&quot;, 
    account.lastname as &quot;Seller Last Name&quot;,
    account.email as &quot;Seller Email&quot;,
    account.phone as &quot;Seller Phone&quot;,
    address.address as &quot;Seller Address (Street)&quot;,
    address.address_2 as &quot;Seller Address 2&quot;,
    account.zip_code as &quot;Seller Zip&quot;,
    address.neighborhood as &quot;Seller Neighborhood&quot;,
    menu.name as &quot;Name of active menu&quot;,
    kitchen_item.name as &quot;Dishes&quot;, 
    kitchen_item.price as &quot;Price&quot;,
    kitchen_item.daily_max_orders as &quot;Quantity&quot;,
    menu.pickup_start_time as &quot;Start time&quot;, 
    menu.pickup_end_time as &quot;End time&quot;,
    menu.repeat_mon as &quot;Monday&quot;,
    menu.repeat_tues as &quot;Tuesday&quot;,
    menu.repeat_wed as &quot;Wednesday&quot;,
    menu.repeat_thurs as &quot;Thursday&quot;,
    menu.repeat_fri as &quot;Friday&quot;,
    menu.repeat_sat as &quot;Saturday&quot;, 
    menu.repeat_sun as &quot;Sunday&quot;,
    order_item.created as &quot;Date of last sale&quot;
    from account
    left join store on account.id = store.account_id
    left join menu on store.id = menu.store_id
    left join menu_item on menu.id = menu_item.menu_id
    left join kitchen_item on (menu_item.kitchen_item_id = kitchen_item.id and store.id = kitchen_item.store_id)
    left join orders on (orders.store_id = store.id)
    left join order_item on (order_item.order_id = orders.id)
    join store_address on store.id = store_address.store_id
    join address on store_address.address_id = address.id
    where orders.placed &gt;= start_date AND orders.placed &lt;= end_date
    order by account.id asc, menu.name, kitchen_item.name asc, order_item.created desc;
END $$;

SELECT * FROM temp_output;