CREATE OR REPLACE FUNCTION public.get_max_week_start_date()
RETURNS DATE AS $$
DECLARE
    latest_date DATE;  -- Variable to hold the latest week_start_date
BEGIN
    -- Select the maximum week_start_date from sjreport
    SELECT max(week_start_date) INTO latest_date FROM sjreport;

    -- Return the latest week_start_date
    RETURN latest_date;
END;
$$
 LANGUAGE plpgsql;
 
select public.get_max_week_start_date()