If you’re getting an error that reads ‘date/time field value out of range‘ in PostgreSQL while using a function such as date_add()
, date_subtract()
, or date_trunc()
, it’s probably because the date value you’re passing to the function is an invalid date.
It’s possible that you’ve got the month and day in the wrong order.
To fix this issue, be sure that you pass a valid date. It may be that all you need to do is switch the day and the month around. Or it could be that you need to change your datestyle
setting.