Context
I developed a dashboard app to display data from PostgreSQL for a client. I have this query to list the Year-Month of a column named stage_updated_at
in both integer and string formats. I'm using this in two dropdown components as Start Month and End Month, serving as a date range filter restricted to months.
WITH date_bounds AS (
SELECT
MIN(stage_updated_at) AS min_date,
MAX(stage_updated_at) AS max_date
FROM
opp_updates_view
),
year_months AS (
SELECT
TO_CHAR(date_trunc('month', (min_date + (generate_series(0,
((EXTRACT(year FROM max_date) - EXTRACT(year FROM min_date)) * 12 +
(EXTRACT(month FROM max_date) - EXTRACT(month FROM min_date)))::integer, 1) * interval '1 month'))) , 'YYYY-MM') AS stage_updated_month,
TO_CHAR(date_trunc('month', (min_date + (generate_series(0,
((EXTRACT(year FROM max_date) - EXTRACT(year FROM min_date)) * 12 +
(EXTRACT(month FROM max_date) - EXTRACT(month FROM min_date)))::integer, 1) * interval '1 month'))) , 'YYYYMM')::INTEGER AS stage_updated_number
FROM
date_bounds
)
SELECT DISTINCT
stage_updated_month,
stage_updated_number
FROM
year_months
ORDER BY
stage_updated_month;
I'm using the integer value as the value and the string for the label. The default value is set to "from the previous to the current" with moment().subtract()
.
Issue
On my browser, which is Chrome on Windows 11, it's working just fine. But on my client's browser, which is also Chrome but on Mac, it's not working properly. It's always like he's in the previous month, with the maximum selectable month being June 2024, and the default start month is two months ago.
I appreciate any pointers.