Alle Geburtstage der nächsten Tage ermitteln

Die folgenden Filterausdrücke für die freie SQL-Abfrage wurden für die Verwendung in der Ansicht „Kontakte“ konzipiert.

Geburtstagen von heute und morgen

Microsoft SQL Server Filterausdruck

SELECT ID
FROM Contacts 
WHERE 
CASE WHEN (DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate())),Birthday) < Convert(date, getdate()) )
THEN DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate()))+1,Birthday)
ELSE DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate())),Birthday) END
BETWEEN Convert(date, getdate()) AND Convert(date, getdate() + 1)

PostgreSQL Filterausdruck

SELECT "ID" FROM "Contacts"
WHERE 
CASE WHEN (SELECT ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') < CURRENT_DATE::date)
THEN (SELECT ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') + interval '1 year')
ELSE ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') END
BETWEEN CURRENT_DATE AND CURRENT_DATE + interval '1 day'

Geburtstage in den nächsten 7 Tagen

Microsoft SQL Server Filterausdruck

SELECT ID FROM Contacts 
WHERE 
CASE WHEN (DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate())),Birthday) < Convert(date, getdate()) )
THEN DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate()))+1,Birthday)
ELSE DATEADD(yyyy,DATEDIFF(yyyy, Birthday, Convert(date, getdate())),Birthday) END
BETWEEN Convert(date, getdate()) AND Convert(date, getdate() + 7)

PostgreSQL Filterausdruck

SELECT "ID" FROM "Contacts"
WHERE 
CASE WHEN (SELECT ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') < CURRENT_DATE::date)
THEN (SELECT ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') + interval '1 year')
ELSE ("Birthday"::date + (EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM "Birthday")) * interval '1 year') END
BETWEEN CURRENT_DATE AND CURRENT_DATE + interval '7 days'
IDKBAD001158 KBAD001158