Date type and 0000-01-01
See original GitHub issueHi,
I have a date field in MySQL table with 0000-01-01 default value. In MySQL it stores correctly, but when I execute a select query I get ‘1900-01-01T00:00:00.000Z’ value.
I think this a bug, because 0000 != 1900
. I’m using this field for user birthday and age calculating. So when I’m trying to calculate a user age I get 118 years old. I handle zero values in my app and I think I should not handle 1900
value.
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Data types (date and numeric formats) - Oracle Help Center
There are three data types in Eloqua: Text, Numeric, and Date/Time. Each data type defines the format of information that can be entered...
Read more >UniPay Gateway Documentation
Type : Entity Status: Active ... Code; Create Date; Fulfillment Center FK ... Values of the bit mask in decimal format (e.g. 00000101)....
Read more >Numbers and dates - JavaScript - MDN Web Docs - Mozilla
A string representing a date in the following form: "Month day, year hours:minutes:seconds." For example, let Xmas95 = new Date("December 25, ...
Read more >Permit Application Status - Bloomington, MN
Application Type: Utility. Application Status: Finaled ... 1 1/2" C2 METER S/N 89388286 READING 00000101. Application Date: 02/02/2021. Issued Date:.
Read more >Format numbers as dates or times - Microsoft Support
To quickly enter the current date in your worksheet, select any empty cell, and then press CTRL+; (semicolon), and then press ENTER, if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works with
dateStrings: true
. Thank you!Works as expected when I pass
dateStrings: true
( sorry in my first comment I said it should be “false”. Meaning of that flag is “don’t try to construct js Date and just return the string as it’s stored”When
dateStrings
is not set resulting date is built here: https://github.com/sidorares/node-mysql2/blob/0da580e52c3ae37832c8fde49dddd56fb88aa52b/lib/packets/packet.js#L541return new Date(y, m - 1, d);
- in your case y is 0, m is 1 and d is 1. I’d say1900-01-01T00:00:00.000Z
is also expected in this case, that’s the way js Date constructor interprets years