Home > other >  How to convert a number to month in bigquery
How to convert a number to month in bigquery

Time:05-03

I have a column like a, and its value like 1, 2, 3, 4, etc stands for each month. 1 stands for January. Now I want to select the data and shown as January, what function should I use?

CodePudding user response:

You can use the function PARSE_DATE to convert your number to a date and then extract the month name using FORMAT_DATE with the parameter %B.

Note that month_column is your column name

SELECT FORMAT_DATE( "%B", PARSE_DATE("%Y-%m-%d",CONCAT('2000-',month_column,'-01') ))
  • Related