find operators like MoreThan and LessThan doesn't work properly for date fields
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[x] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
find operators like MoreThan and LessThan doesn’t work properly for date fields. some investigation showed that sqlite stores dates like 2018-06-05 15:57:27.249
but the query is like ... WHERE "User"."createdAt" > ? -- PARAMETERS: ["2018-06-05T01:01:32.650Z"]
meaning it queries in ISO date format. when you just need comparison till day factor, it doesnt look like a problem but when you also need the time/hours/mins/etc then it doesnt return proper results. i only tested for sqlite so i dont know if same problem goes for other dbs.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:30
- Comments:13 (2 by maintainers)
@enif-lee Ok thanks. I usually use an other one: https://www.npmjs.com/package/date-fns You just don’t use the parameter date and you force new Date() in your function. Here is an update if someone is interested:
I was doing unit testing and found this problem, how is this still open for so long… very basic functionallity for an ORM.
I have a postgres db with timestamp fields in my entity, this is what I ended up using to make it work: