AnsweredAssumed Answered

How can I sort a date via SQL for a list of currnt birthdays?

Question asked by disabled_Luna.media on Mar 19, 2016
Latest reply on Mar 23, 2016 by user19752

Hi,

 

I want to show all the current birthdays in my CRM in a list of my startup window from, say: today and the next seven days. For that I do use a field that holds all the IDs of the contacts and a the contacts do relate to this list of IDs. The birthdays look like "01.02.2016".

 

To get the IDs of the contacts that do have birthday in the next days I use an eSQL-statement - but this ne here does not work in two ways:

 

  1. I do also get "old" birthdays before today
  2. they do not sort correctly

 

SQLAusführen ( "

    SELECT

        DISTINCT ID

    FROM

        contacts

    WHERE

        ( Day ( birthday ) >= ? OR Day ( birthday ) <= ? )

        AND

         Month ( birthday ) = ?

    ORDER BY

        Day ( birthday )

    " 

    ; "" ; ""

    ; WochentagZahl ( Hole ( SystemDatum ) )

    ; WochentagZahl ( Hole ( SystemDatum ) ) + 7

    ; MonatZahl ( Hole ( SystemDatum ) ) 

)

 

Any ideas?

Outcomes