Search code examples
google-bigquery

How to get Day name in Google BigQuery


How to get the name of the day from date in Google BigQuery.

I can achieve this by below query

SELECT CASE WHEN DAYOFWEEK(CURRENT_DATE())=1 THEN 'Sunday' WHEN DAYOFWEEK(CURRENT_DATE())=2 THEN 'Monday'
             WHEN DAYOFWEEK(CURRENT_DATE())=3 THEN 'Tuesday' WHEN DAYOFWEEK(CURRENT_DATE())=4 THEN 'Wednesday'
             WHEN DAYOFWEEK(CURRENT_DATE())=5 THEN 'Thusday' WHEN DAYOFWEEK(CURRENT_DATE())=6 THEN 'Friday'
             WHEN DAYOFWEEK(CURRENT_DATE())=7 THEN 'Saturday' END as [DOW]

If there is any default function available to get name of the day?


Solution

  • No there isn't. According to the docs on query reference (which you should bookmark :) ), most specifically the DateTime ones .

    You can get the number of the day with DAYOFWEEK(), as you have in your query. But that's it.