HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Shorthand for epoch

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
epochforshorthand

Problem

Is there a shorthand for the epoch instead of having to type '1970-1-1 00:00:00' all the time?

Solution

It is surprisingly 'epoch'

select 'epoch'::timestamp;
timestamp
1970-01-01 00:00:00
(1 row)

select TIMESTAMP 'epoch';
timestamp
1970-01-01 00:00:00
(1 row)


Special date/time inputs are described in the section 8.5.1.4 here:

Code Snippets

select 'epoch'::timestamp;
timestamp
1970-01-01 00:00:00
(1 row)

select TIMESTAMP 'epoch';
timestamp
1970-01-01 00:00:00
(1 row)

Context

StackExchange Database Administrators Q#156098, answer score: 5

Revisions (0)

No revisions yet.