Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

latz's avatar
Level 3

Translate sql to query builder

Hello,

i have this raw sql-query:

 SELECT firstname, lastname, to_char(birthday, 'DD.MM.YYYY') as birthday
    FROM players
    WHERE (extract(year from age(birthday)) + 1) *  interval '1 year' + birthday between current_date and now() + '60 days'
    ORDER by EXTRACT(Month FROM birthday), EXTRACT(Day FROM birthday) 

I have problems to build the select with the query builder.

My first try:

        ->select('firstname', 'lastname', 'to_char(birthday, 'DD.MM.YYYY') as birthday')
    ...

doesn't work. How can i use 'to_char' and 'as'??

0 likes
1 reply

Please or to participate in this conversation.