Group by quarter issue , diferent view in GUI and SQL editor

I am trying to undestand why when I changed the GUI view of a card to SQl , metabase change the name of Quarters from ex. Q1.2021 to January 1,2021, I need to keep the "Q #- year" style instead of month. Could you help me with this?

Then if go to SQL view of this question ( same question ) and hit run, it changes the name of the quarter to month.

Hi @aramit
Only GUI questions know that you are returning some granularity. For SQL, you will have to do such formatting manually.

Hi @flamber, and thanks for your prompt response , can you help me how it can be done manually? I greatly appreciate it, if you can provide me an example

@aramit I don't know which database type you're using, but you would use date_format()/to_char() or similar depending on your database type. Try searching your database documentation for "date formatting"

Thanks @flamber version is v1.43.4 and it is postgreSQL.I am puzzled among the instructions, can you share your comments, Could I ask you to help me with this?

i found it to_char(date_trunc('quarter', "public"."table"."created_at"), '"Q"Q YYYY') AS "created_at"

@aramit Exactly. Reference for others: https://www.postgresql.org/docs/current/functions-formatting.html

BTW @flamber thank you as always being helpful! appreciate it !

1 Like