Lourdes Hernández
Lourdes Hernández

Reputation: 291

Dynamic TABLE_DATE_RANGE in BigQuery

Is there a way of using a date variable as an argument of TABLE_DATE_RANGE()?

I mean, my goal is to analyze the behavior of users in the next week after they've purchased.

What I try to get is something like that:

TABLE_DATE_RANGE([mydata.], 
                TIMESTAMP(purchaseDate), 
                TIMESTAMP(DATE_ADD(purchaseDate,7,'DAY')))  

where I've previously calculated 'purchaseDate', querying a fixed period of time. This will make dynamic the queried time range for each user. I'm not sure if this approach is against the BQ structure logic.

Upvotes: 2

Views: 781

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172974

TABLE_DATE_RANGE will not accept any field names at least because none available at a time of evaluation

Upvotes: 3

Related Questions