-
Couldn't load subscription status.
- Fork 350
Description
issue
MSSQL datetime only stores time to an accuracy of ~3.33 milliseconds. This means when you insert a JS date into a datetime column, SQL Server rounds the fractional seconds to the nearest 0, 3, or 7 ms increment.
Example:
JS: 2025-09-26T01:00:00.001Z
MSSQL stored: 2025-09-26T01:00:00.003Z
solution
In order to resolve this, we must create the datetime field as datetime2 - however as of now using db.schema.alterTable(...).addField("name", "datetime2", ...) won't work.
For more context, here's a post on stackoverflow talking about this specific issue regarding mssql:
https://stackoverflow.com/questions/7823966/milliseconds-in-my-datetime-changes-when-stored-in-sql-server
Additional info:
I require the .addField specifically as this is being built into a wrapper function used in the better-auth repo.