0004
0004

Reputation: 1260

BigQuery Date Diff

Having a lot of trouble working with bigquery and this error message on the code below:

No matching signature for function PARSE_DATE for argument types: STRING, TIMESTAMP. Supported signature: PARSE_DATE(STRING, STRING) at [4:5]

DATE_DIFF(
    PARSE_DATE('%Y%m%d', created_at), 
    PARSE_DATE('%Y%m%d', closed_at), 
    DAY
  ) days

Upvotes: 1

Views: 77

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

Based on error message - created_at and closed_at are timestamp datatype, so you can use below

DATE_DIFF(
    DATE(created_at), 
    DATE(closed_at), 
    DAY
  ) days    

or just simply

TIMESTAMP_DIFF(
    created_at, 
    closed_at, 
    DAY
  ) days    

Upvotes: 1

Related Questions