Mayank
Mayank

Reputation: 407

Google BigQuery-TimeZone Conversion

I have a requirement to convert UTC datetime field to est in bigquery using Standard SQL

I tried below Query:

SELECT
  CallRailCallId,

  DATETIME(StartTime ,
    "America/Los_Angeles") AS adjustedTime
FROM
  `Tablel`

But I got this error as below :

No matching signature for function DATETIME for argument types: DATETIME, STRING. Supported signatures: DATETIME(INT64, INT64, INT64, INT64, INT64, INT64); DATETIME(DATE, TIME); DATETIME(TIMESTAMP, [STRING]); DATETIME(DATE)

Can anyone help in this, what wrong with my query?

Upvotes: 0

Views: 5547

Answers (1)

Elliott Brossard
Elliott Brossard

Reputation: 33705

You can convert it to a timestamp first, then interpret it in a particular time zone.

SELECT
  CallRailCallId,
  DATETIME(TIMESTAMP(StartTime),
    "America/Los_Angeles") AS adjustedTime
FROM
`Tablel`

Upvotes: 5

Related Questions