Anthony Kong
Anthony Kong

Reputation: 40814

How to obtain a bigint from a date?

Running it

SELECT timestamp '2019-6-2 00:00 UTC'

will return a date representation to me

enter image description here

then I want to obtain it as a bigint,

SELECT cast(timestamp '2019-6-2 00:00 UTC' as bigint)

I got this error

Query failed (#20190604_014249_16755_mru2t): line 1:8: Cannot cast timestamp with time zone to bigint

Upvotes: 0

Views: 128

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270713

What bigint do you want? One reasonable answer is a unix timestamp:

select cast(to_unixtime(timestamp '2019-6-2 00:00 UTC') as bigint)

Upvotes: 4

Related Questions