mithrandie / csvq

SQL-like query language for csv
https://mithrandie.github.io/csvq
MIT License
1.49k stars 65 forks source link

--datetime-format #74

Closed derekmahar closed 2 years ago

derekmahar commented 2 years ago

Given

$ csvq "SELECT DATETIME('2021-01-02 11:22:33') AS DateTime"
+----------------------------+
|          DateTime          |
+----------------------------+
| 2021-01-02T11:22:33-05:00  |
+----------------------------+

shouldn't

$ csvq --datetime-format '%d/%m/%y %T' "SELECT DATETIME('02/01/2021 11:22:33') AS DateTime"
+----------+
| DateTime |
+----------+
|   NULL   |
+----------+

produce the same result instead of NULL?

$ csvq --version
csvq version 1.16.0
ondohotola commented 2 years ago

csvq --datetime-format '%d/%m/%Y %T' "SELECT DATETIME('02/01/2021 11:22:33') AS DateTime"

On 2022-04-05 21:37 , Derek Mahar wrote:

Given

|$ csvq "SELECT DATETIME('2021-01-02 11:22:33') AS DateTime" +----------------------------+ | DateTime | +----------------------------+ | 2021-01-02T11:22:33-05:00 | +----------------------------+ |

shouldn't

|$ csvq --datetime-format '%d/%m/%y %T' "SELECT DATETIME('02/01/2021 11:22:33') AS DateTime" +----------+ | DateTime | +----------+ | NULL | +----------+ |

produce the same result instead of NULL? [...]

el

-- Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist @.** / | Telephone: +264 81 124 6733 (cell) PO Box 8421 Bachbrecht \ / If this email is signed with GPG/PGP 10007, Namibia ;____/ Sect 20 of Act No 4 of 2019 may apply

derekmahar commented 2 years ago

Thank you for correcting my error. I can hardly believe that I spent a few hours trying to solve this problem when all that I had to do was replace lower case "%y" with upper case "%Y".

ondohotola commented 2 years ago

man date :-)-O

The lower case %y does not exist, hence the error :-)-O

el

On 06/04/2022 01:25, Derek Mahar wrote:

Thank you for correcting my error. I can hardly believe that I spent a few hours trying to solve this problem when all that I had to do was replace lower case "%y" with upper case "%Y".

— Reply to this email directly, view it on GitHub https://github.com/mithrandie/csvq/issues/74#issuecomment-1089514992, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVZVGS52ZYFTHQOPOJMEW3VDTDU5ANCNFSM5STY7QFQ. You are receiving this because you commented.Message ID: @.***>

-- Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist @.** / | Telephone: +264 81 124 6733 (cell) PO Box 8421 Bachbrecht \ / If this email is signed with GPG/PGP 10007, Namibia ;____/ Sect 20 of Act No. 4 of 2019 may apply

derekmahar commented 2 years ago

Actually, the documentation for function DATETIME_FORMAT and the man page for date both specify that lower case %y is a placeholder for the last two digits of the year. Next time, I should wear my glasses when I read technical documentation.