Skip to content

How to request relative date (ie, CURRENT_DATE - 30) #2947

Answered by wolfgangwalther
getglad asked this question in Q&A
Discussion options

You must be logged in to vote

PostgreSQL has two different "now"s:

  • A function now(), which returns the same as CURRENT_TIMESTAMP. This is the similar to CURRENT_DATE. You seem to assume you are calling this with lt.now, but you are not.
  • A special value which can be read as input for timestamptz or date types. This is what you are using with lt.now.

There is no such special input value for timestamptz or date for "current_date". That's the error message you are seeing.

Also see the PG docs in 8.5.1.4. Special Values:

The following SQL-compatible functions can also be used to obtain the current time value for the corresponding data type: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, LOCALTIME, LOCALTIMESTAMP. [...] …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants