In the docs I could only find a way to create a date from a string, e.g. DATE '2000-01-02'
. This is utterly confusing and annoying. What I want instead is a function that takes three parameters, so I could do make_date(2000, 1, 2)
and use integers instead of strings, and returns a date (not a string). Does PostgreSQL have such a built-in function?
The reason I'm asking this is because I dislike the use of strings for things that are not strings. Dates are not strings; they're dates.
The client library I use is HDBC-PostgreSQL for Haskell. I'm using PostgreSQL 9.2.2.
In PostgreSQL 9.4 and greater there is actually a make_date(year int, month int, day int)
function that will create a date.
http://www.postgresql.org/docs/9.5/static/functions-datetime.html