exploding_data
exploding_data

Reputation: 307

How to get month name from partition time in Bigquery

I need to extract month number from current_date() in BigQquery. I am using below sql statement that extracts month name .How to get month number:

Select MONTH(current_date())

Any suggestion?

Upvotes: 1

Views: 537

Answers (1)

Sergey Geron
Sergey Geron

Reputation: 10172

Try EXTRACT to extract month number from date:

SELECT EXTRACT(MONTH FROM CURRENT_DATE())

Try FORMAT_TIMESTAMP to extract month name from timestamp:

SELECT FORMAT_TIMESTAMP('%B', _PARTITIONTIME) FROM tablename

Upvotes: 3

Related Questions