MSSQL's datetime2 has a default microsecond precision of 7. However, Elixir's Calendar only supports a precision of 6:
@type microsecond :: {0..999_999, 0..6}
Using the following in migrations works when inserting rows from Ecto:
timestamps(inserted_at: :created_at, type: :datetime2)
Schema uses type :utc_datetime:
timestamps(inserted_at: :created_at, type: :utc_datetime)
Once a row is inserted outside of Ecto using getutcdate() or in the format '2007-05-02T19:58:47.1234567' with the default precision of 7, Ecto fails to print the date:
It looks like Ecto 3.0 will be removing microseconds with :utc_datetime and other types mentioned in their changelog
and adding :utc_datetime_usec which will keep them.
MSSQL's datetime2 has a default microsecond precision of 7. However, Elixir's
Calendar
only supports a precision of 6:@type microsecond :: {0..999_999, 0..6}
Using the following in migrations works when inserting rows from Ecto:
timestamps(inserted_at: :created_at, type: :datetime2)
Schema uses type
:utc_datetime
:timestamps(inserted_at: :created_at, type: :utc_datetime)
Once a row is inserted outside of Ecto using
getutcdate()
or in the format'2007-05-02T19:58:47.1234567'
with the default precision of 7, Ecto fails to print the date:Update:
It looks like Ecto 3.0 will be removing microseconds with
:utc_datetime
and other types mentioned in their changelog and adding:utc_datetime_usec
which will keep them.