Steve
Steve

Reputation: 125

Firebase Analytics: export data to BigQuery as a date

I'm trying to log events and specify the moment these moments happened.

For example:

Firebase.Analytics.FirebaseAnalytics.LogEvent ("EventGamePlayed", "sent_at", DateTime.Now.ToString ("yyyy-MM-dd hh:mm:ss"));

I would like to know if it's possible that, once it's exported to BigQuery, I could use this parameter as a date / timestamp so I can, for example, get all the X or Y events that happened last month.

Thanks!

Upvotes: 3

Views: 2641

Answers (1)

Elliott Brossard
Elliott Brossard

Reputation: 33725

You probably don't need this, actually. Referring to the Firebase schema for BigQuery exports, you can use either date or timestamp_micros within event_dim. For example, to find events on April 1, you could do:

#standardSQL
SELECT event
FROM YourTable
CROSS JOIN UNNEST(event_dim) AS event
WHERE PARSE_DATE('%Y%m%d', event.date) = '2017-04-01';

To find events that occurred between 12pm and 4pm UTC on April 1, you could do:

#standardSQL
SELECT event
FROM YourTable
CROSS JOIN UNNEST(event_dim) AS event
WHERE TIMESTAMP_MICROS(event.timestamp_micros) BETWEEN
  '2017-04-01 12:00:00' AND '2017-04-01 16:00:00';

Upvotes: 5

Related Questions