Search code examples
google-sheetsstring-formattinggoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Changing the Format of a Column from QUERY function in Google Sheet


I am currently using this formula to list users that have a Birthday this month

=QUERY(Data!$A:$K, "Select C,D,J WHERE Month(J)+1 matches '"& Month(Today()) &"' ", 1 )

I get a list of users that list their First Name, Last Name, and Birthdate for users that have a birthday in the current month.

Is it possible to return the 3rd column (birthdate) in a different format? Such as let's say I want to use Text(J, "mm-dd")?

I tried

=QUERY(Data!$A:$K, "Select C,D,TEXT(J, '"mm-dd"' WHERE Month(J)+1 matches '"& Month(Today()) &"' ", 1 )

But I get a formula parse error. I am guessing I can't do formulas within the query, but just wanted to see if anyone has input.


Solution

  • depends... you can use QUERY parameter format

    enter image description here

    so it would be:

    =QUERY(Data!$A:$K, 
     "select C,D,J 
      where month(J)+1 matches '"&MONTH(TODAY())&"'
      format J 'mm-dd'", 1)
    

    but this depends on your dataset...