How to convert date type to unixtimstamp?

Hello,

I need to convert my date to a unixtimestamp in Metabase. I'm using a PostgreSQL server.

I'm able to retreive the unix timestamp :
SELECT extract(epoch from timestamp '2023-02-27 00:00:00')

But I can't retreive using Metabase variable :
SELECT extract(epoch from timestamp {{period_start}})
It throws me

syntax error near to « $1 » Position : 1176

I also tried

WITH temp AS (
    SELECT CONCAT({{period_start}},' 00:00:00') AS "TIME"
)

SELECT extract(epoch from timestamp "TIME") FROM temp

It output : syntax error near « "TIME" » Position : 1235

I'm pretty sure it's because the Metabase parameter is not passed a a "pure" timestamp

try SELECT extract(epoch from timestamp {{period_start}}::timestamp)

1 Like