sqlstyle.guide icon indicating copy to clipboard operation
sqlstyle.guide copied to clipboard

ISO Date/Time Format

Open felher opened this issue 3 years ago • 1 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"?

felher avatar Dec 03 '21 12:12 felher

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.

treffynnon avatar May 29 '22 23:05 treffynnon

Great! Thank you :)

felher avatar Feb 29 '24 17:02 felher