Thank you Tom for your answer and your work on open source projects.
regards,
Sébastien Caunes
Le jeu. 30 sept. 2021 à 15:35, Tom Lane <tgl@sss.pgh.pa.us> a écrit :
Sébastien Caunes <sebastien@pixseed.fr> writes: > TO_DATE function should reject the time part (HH24:MI:SS) in the template > string.
We're not going to do that, because it would break interesting use-cases. It's true that you could just omit the time part of the format in the example you gave. But if you want to parse data with the time part appearing first, that doesn't work:
regression=# select TO_DATE('08:30:37 2021-09-30', 'YYYY-MM-DD'); ERROR: date/time field value out of range: "08:30:37 2021-09-30"
> I just saw developers coming from Oracle spending a lot of time on this.
A rule of thumb for people coming from Oracle is that uses of to_date and related functions should be nuked from orbit. For just about any common datetime layout, simply casting to the desired type is safer and easier: