PostgreSQL - yesterday, today, tomorrow, now example - TIMESTAMP, DATE, TIME examples
daniel Mon, 06/28/2010 - 10:14am
Looking at the PostgreSQL, I stumbled across the nice little gems of (yesterday, today, tomorrow, allballs, now). However, having little postgresql experience, I had a bit of trouble figuring out how they are to be used...
You might think they would be functions in the same manner as "now()"
but, alas, no.
Looking a little closer at the documentation, they need to be used with the TIMESTAMP or DATE keywords.
You might think that this is a function and try
but that won't work either.
The proper use is like any other sql KEYWORD
select TIMESTAMP 'yesterday';
select DATE 'yesterday';
select TIMESTAMP 'today';
select DATE 'today';
select TIMESTAMP 'tomorrow';
select DATE 'tomorrow';
select TIME 'allballs';
select TIMESTAMP 'now';
select DATE 'now';
further reading on dates and times