Reputation: 2652
I'm working with Google Analytics data in a Google Big Query table using standard sql. I wish to select group data at a weekly level. I've found this solution:
SELECT FORMAT_TIMESTAMP("%W", PARSE_TIMESTAMP("%Y%m%d", '20150519'))
Outputs:
20
Is there a shorter method to get to this point? It seem quite long to me and I'm wondering if I'm missing a trick.
Upvotes: 0
Views: 397
Reputation: 172993
The only "improvement" I see can be done - is using PARSE_DATE
instead of PARSE_TIMESTAMP
SELECT FORMAT_DATE("%W", PARSE_DATE("%Y%m%d", '20150519'))
Upvotes: 1