PostgreSQL yesterday, today, tomorrow, now

PostgreSQL example – yesterday, today, tomorrow, now

  • select TIMESTAMP ‘yesterday’;
    2016-05-05 00:00:00
  • select DATE ‘yesterday’;
    2016-05-05
  • select TIME ‘allballs’;
    00:00:00

You can use similar convenient method for today and tomorrow:

  • select TIMESTAMP ‘today’, DATE ‘today’;
  • select TIMESTAMP ‘tomorrow’, DATE ‘tomorrow’;
  • select now(), TIMESTAMP ‘now’, DATE ‘now’;

BTW: what is ‘allballs’?

It’s used to denote midnight UTC, someone said it’s because midnight UTC is all zeros, 00:00:00.00 which looks like a bunch of balls.

Now – 1 day, -1 hour, -1 minute

  • select now() – interval ‘1 day’
  • select now() – interval ‘1 hour’
  • select now() – interval ‘1 minute’
(Visited 47 times, 1 visits today)

Leave a Reply