Hi,
I have a table with public holidays for the next couple of years. As I want to display future public holidays for a certain time range only, I'm trying (and crying) to create a SELECT statement which returns all dates from today to six months in the future.
With this SELECT I can display all rows from today:
SELECT
CASE
WHEN 6 - WEEKDAY('date') = 2 OR WEEKDAY('date') - 1 = 1 THEN CONCAT('name', " + ", "Brückentag")
ELSE name
END AS 'Feiertag', 'date' AS 'Datum', 'scope' AS 'Geltungsbereich', WEEKDAY('date') AS 'Wochentag'
FROM T1
WHERE CAST('date' AS DATE) > GETDATE()
ORDER BY 'date' ASC
To get just the dates for the coming six months, I tried, amongst others, the following solutions which all returned 0 rows:
- WHERE CAST('date' AS DATE) BETWEEN GETDATE() AND DATEADD(month, -6, getdate())
- WHERE CAST('date' AS DATE) BETWEEN GETDATE() AND DATE_ADD(GETDATE(), INTERVAL 6 MONTH)
- WHERE 'date' < DATEADD(month, 6, GETDATE())
- WHERE CAST('date' AS DATE) < DATEADD(month, 6, GETDATE())
I also tried to find all rows until the end of the current year but this only worked with a hardcoded "2023-01-01".
Any ideas for an nice solution?
Thanks,
Eishle