Hello there and Happy New Year!
Every monday I need to run this automate MySQL query in a sProc on a date between the first day of the year and eight days back from today.
SELECT
MAKEDATE( YEAR ( now()), 1 ) start_date,
DATE_SUB( CURRENT_DATE, INTERVAL 8 DAY ) end_date
FROM
`tbl1`
WHERE
the_date BETWEEN MAKEDATE( YEAR ( now()), 1 )
AND DATE_SUB( CURRENT_DATE, INTERVAL 8 DAY );
But today is the first monday of the new year and if i run the query the output is empty because the start date is greater than the end date.
start_date >>> MAKEDATE( YEAR ( now()), 1 ) = 2025-01-01
end_date >>> DATE_SUB( CURRENT_DATE, INTERVAL 8 DAY ) = 2024-12-29
How to do resolve this?
Maybe checking that today’s date is the first Monday of the year?
Any help really appreciated