You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting previous day instead of current for MSSQL DATEONLY #10231
Output, either JSON or SQL
SQL returns '1992-10-10'
Actual result is '1992-10-09'
Dialect: mssql Dialect version: 4.1.0 Database version: XXX Sequelize version: 5.0.0-beta.14 Tested with latest release: No (If yes, specify that version)
I did my research and i found that in data-types.js in the dialect was doing the following
return moment(value).format('YYYY-MM-DD');
based on this code i can infer that its expecting value to be either an iso format or a date object. it is indeed getting a moment object but with a parsed time in GM (Sat May 05 2018 20:00:00 GMT-0400) so when formatting to 'YYYY-MM-DD' it gets the previous day.
i changed it to
``return moment.utc(value).format('YYYY-MM-DD');`
and it started working. i am not making this a PR because i dont think this is the right approach based on what ive seen and that im not a sequelize expect.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Activity
stale commentedon Mar 5, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
dengue8830 commentedon Oct 22, 2019
same problem here, i fixed adding 1 day to the obtained date 😢