Bad date format with SQL database
See original GitHub issueWith SQL database (PostgreSQL), feathers-auth-management doest not work out of the box, because of the use of Date.now()
instead of new Date()
.
I got errors like this:
{
"name": "BadRequest",
"message": " date/time field value out of range: \"1516020161065\"",
"code": 400,
"className": "bad-request",
"errors": {}
}
Maybe you should consider using new Date()
instead of Date.now()
, to use actual Date.
Regards.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Bad date format change from string to date in Bigquery
NB: I did not apply an ORDER BY clause to the Results hence the data is not ordered by any specific column in...
Read more >Bad date format with SQL database · Issue #86 - GitHub
Hi, I got this error error: RequestError: Operand type clash: bigint is incompatible with date when using the date type in SQL Server...
Read more >Access front - SQL back wrong date format issue - MSDN
In SQL the date format is yyyy/mm/dd and on my Access backend and frontend the date format is mm/dd/yyyy. But as the queries...
Read more >Caught bad date format with exact error - Oracle Communities
As an aside, why are your trying to assign a timestamp to a DATE? A DATE only resolves down to a second, and...
Read more >How to Get SQL Server Dates and Times Horribly Wrong
The numeric format is considered to be a more universal way to pass in time-date data. After all, that's how SQL Server returns...
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 FreeTop 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
Top GitHub Comments
I realize this is a few years later but I ran into the same problem and have a simpler fix. The above solution from @morenoh149 works but then the data is stored as an int rather than the proper datetime format. I’m using Objection, and it was easy to do the data conversion in the Objection model file thusly:
users.model.js:
The main part is the $beforeInsert and $beforeUpdate functions, which check to see if the verifyExpires or resetExpires fields are numbers, and then recasts them to the proper Date value. This works and leaves your postgresql database with the proper field types.
Read this about coercing data types for Sequelize and Knex https://github.com/feathers-plus/authentication-local-management/blob/master/misc/upgrading.md
You can do so using a hook similar to this https://github.com/feathers-plus/authentication-local-management/blob/master/src/hooks/conversion-sql.js