treffynnon/sqlstyle.guide

ISO Date/Time Format

felher opened this issue · 2 comments

Hey folks,

the guide states

Store ISO 8601 compliant time and date information (YYYY-MM-DD HH:MM:SS.SSSSS).

I read that as "store it in this format" - but as far as I know, ISO either requires a T between date and time or having nothing there, but not a space.

See https://stackoverflow.com/questions/9531524/in-an-iso-8601-date-is-the-t-character-mandatory

Maybe the T should be included in the ISO string?
Or maybe my reading was wrong and it does not mean "store in that format"?

You're correct that it must have a T to be ISO 8601. From the PostgreSQL manual:

ISO 8601 specifies the use of uppercase letter T to separate the date and time. PostgreSQL accepts that format on input, but on output it uses a space rather than T, as shown above. This is for readability and for consistency with RFC 3339 as well as some other database systems.

Great! Thank you :)