Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum date that can be stored in Postgres

Tags:

postgresql

I want to store date like "247530526765-12-27" in DB. But I am getting the following error IO Error pq: date/time field value out of range: "247530526765-12-27"

I understand the year field of my date is too odd. But still I want to know whether it is possible. If yes, how do I increase the maximum range of DATE.

like image 268
Jsmith Avatar asked Sep 17 '25 21:09

Jsmith


1 Answers

Postgres's date type is only 4 bytes wide, so it can't store anything beyond the year 5874897. There is not a way to increase it.

With a little work in your client, you could store the date in a wide numeric type like a bigint as "days from epoch" or something similar. Or you could always serialize the date to a string.

like image 116
Kristján Avatar answered Sep 19 '25 11:09

Kristján