Ecto automatically rejects format conversions which would lose precision, including storing a date with 1-microsecond precision to a column which only has 1-second precision. For this reason, datetimes must be truncated before storing.
Elixir v1.15 added DateTime.utc_now/1, which accepts an argument indicating that the returned value should be truncated, eliminating the need to explicitly truncate it in a second step.
Ecto automatically rejects format conversions which would lose precision, including storing a date with 1-microsecond precision to a column which only has 1-second precision. For this reason, datetimes must be truncated before storing.
Elixir v1.15 added
DateTime.utc_now/1
, which accepts an argument indicating that the returned value should be truncated, eliminating the need to explicitly truncate it in a second step.