Skip to content

Date field in Avo reduces datetime by one day upon update #3929

@adrienpoly

Description

@adrienpoly

Describe the bug

Assuming an ActiveRecord datetime attribute named period_end_at.

In the Avo admin interface, I only care about the date portion of this attribute — not the time — so I’ve defined the field as:

field :period_end_at, as: :date

However, when I update the resource in the UI (even without modifying the field), the stored value is reduced by one day.

For example:

  • I select June 6 in the admin.
  • After saving, the value in the database becomes June 5, typically at 23:00 or another adjusted time depending on the time zone.

Expected behavior & Actual behavior

  • Expected behavior: When a datetime is cast to a date, saving it should preserve the same calendar date (e.g., June 6 should remain June 6).

  • Actual behavior: The date is shifted back by one day, which introduces subtle bugs.

System configuration

Avo version: latest

Rails version: 8

Ruby version: 3.4.4

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

CleanShot.2025-06-06.at.16.06.25.mp4

Just edit the field without changing anything

CleanShot.2025-06-06.at.16.08.56.mp4

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

It lead to rather tricky bugs in our app when admin would edit a field without touching the date and is updated teh date

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions