Skip to content

DATETIMEFORMAT on a Date returns the previous day #246

Description

@cesarParra

DATETIMEFORMAT applied to a Date returns the day before.

Repro

expression.Evaluator.run('DATETIMEFORMAT(DATE(2026,9,9), "MMMM d, yyyy")', someId);
// => September 8, 2026

expression.Evaluator.run('TEXT(DATE(2026,9,9))', someId);
// => 9/9/2026

Expected: September 9, 2026.
Actual: September 8, 2026 — one day earlier.

The same shift appears on Date fields, not just DATE() literals: a field holding 2026-09-09
formats as September 8.

Running org's timezone is behind UTC, which is presumably the cause — the Date looks like it is
being widened to a DateTime at midnight UTC and then rendered in the local timezone, moving it back
a day. A Date has no time and no zone, so formatting one should never shift it.

TEXT() on the same value is correct, so the two functions disagree about what the date is.

Why it matters

Silent and plausible. A due date, an expiration date or an invoice date renders one day early and
nothing about the output looks wrong — you only catch it by comparing against the record. Any
formatted date in a customer-facing document is affected.

Environment

Expression 1.52.0.1, Developer Edition scratch org, org timezone behind UTC.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions