+49 (0)7531 906010| service@combit.net

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.

Um alle Kontakte mit Geburtstagen von heute und morgen zu ermitteln, verwenden Sie folgende Filterausdrücke:
Microsoft SQL Server Filterausdruck

SELECT ID 
FROM Contacts 
WHERE Birthday = 
(CASE 
WHEN (datepart(dayofyear, convert(datetime, '31.12.' + cast(datepart(year, getdate()) as varchar), 104)) = 365) AND (datepart(dayofyear, Birthday) >= datepart(dayofyear, getdate())) AND (datepart(dayofyear, Birthday) < datepart(dayofyear, getdate()) + 2) THEN Birthday
WHEN (datepart(dayofyear, getdate()) + 1) - datepart(dayofyear, convert(datetime, '31.12.' + cast(datepart(year, getdate()) as varchar), 104)) > datepart(dayofyear, Birthday) THEN Birthday 
END)


PostgeSQL Filterausdruck

SELECT "ID" 
FROM "Contacts" 
WHERE "Birthday" = 
(CASE
WHEN (date_part('doy', date(date_part('year', current_date) || '-12-31')) = 365) AND (date_part('doy', "Birthday") >= date_part('doy', current_date)) AND (date_part('doy', "Birthday") < date_part('doy', current_date) + 2) THEN "Birthday" 
WHEN (date_part('doy', current_date) + 1) - date_part('doy', date(date_part('year', current_date) || '-12-31')) > date_part('doy', "Birthday") THEN "Birthday" 
END)



Um alle Datensätze mit Geburtstagen in den nächsten 7 Tagen zu ermitteln, verwenden Sie folgende Filterausdrücke:
Microsoft SQL Server Filterausdruck

SELECT ID 
FROM Contacts 
WHERE Birthday = 
(CASE 
WHEN (datepart(dayofyear, convert(datetime, '31.12.' + cast(datepart(year, getdate()) as varchar), 104)) = 365) AND (datepart(dayofyear, Birthday) >= datepart(dayofyear, getdate())) AND (datepart(dayofyear, Birthday) < datepart(dayofyear, getdate()) + 7) THEN Birthday
WHEN (datepart(dayofyear, getdate()) + 7) - datepart(dayofyear, convert(datetime, '31.12.' + cast(datepart(year, getdate()) as varchar), 104)) > datepart(dayofyear, Birthday) THEN Birthday 
END)


PostgreSQL Filterausdruck

SELECT "ID" 
FROM "Contacts" 
WHERE "Birthday" = 
(CASE
WHEN (date_part('doy', date(date_part('year', current_date) || '-12-31')) = 365) AND (date_part('doy', "Birthday") >= date_part('doy', current_date)) AND (date_part('doy', "Birthday") < date_part('doy', current_date) + 7) THEN "Birthday" 
WHEN (date_part('doy', current_date) + 7) - date_part('doy', date(date_part('year', current_date) || '-12-31')) > date_part('doy', "Birthday") THEN "Birthday" 
END)
IDKBAD001158 KBAD001158

© combit GmbH