user37203
user37203

Reputation: 706

timestamp format in google bigquery loses

As per another question, i've been doing this (python) to push my timestamps into bigquery (they come from a node-js app in a nr-of-miliseconds format):

e["createdOn"] = e["createdOn"] / 1000.0

But they end up as this:

SELECT updatedOn,TIMESTAMP_TO_USEC(updatedOn) FROM [table.sessions] WHERE session = xxxxxxx
Row updatedOn f0_    
1 2014-08-18 11:55:49 UTC 1408362949426000
2 2014-08-18 11:55:49 UTC 1408362949426000 

I've been printing debug information, and this is their last form before being inserted with insertAll:

{u'session': 100000000000080736, u'user': 1000000000075756, u'updatedOn': 1409052076.223}

Upvotes: 5

Views: 1571

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26617

I think you're confusing USEC (microseconds) and MSEC (milliseconds). You're providing the timestamp in milliseconds, but you're then converting to microseconds, which will have the last three digits as 0 because that is higher precision than you provided.

If you use the TIMESTAMP_TO_MSEC function instead, it should do what you expect.

Upvotes: 2

Related Questions