Function field (glidefunction) based on approved_end_date returns an extra day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I am facing an issue when configuring a Function Field (glidefunction) on the pm_project table to extract and format the date from the approved_end_date field.
The issue: When applying string manipulation functions (such as substring and concat) to parse the date into a DD-MM-YYYY format, the resulting value always displays one extra day compared to the actual date stored in the original record.
How can I properly structure or handle this function field so that it returns the exact calendar day without adding that extra day?
Thanks in advance for your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @DanielIsaiVela,
This is a timezone issue, not a problem with your substring/concat logic — that logic itself is fine.
approved_end_date is a Date/Time (GlideDateTime), so it is stored in UTC. A function field is evaluated server-side in the system (instance) timezone, while the form shows you the same value converted to your own timezone. When the stored time is late enough in the day, those two conversions land on different calendar days, and your substring then faithfully reformats the already-shifted day — which is why you consistently get one extra day. The same pattern is in the linked thread "Question on timezone formatting for a function field", where any planned_start from 16:00 onward rolled over to the next day.
You can confirm it quickly: look at the time portion of approved_end_date (for example via Show XML on the record). You should see a late-day time on the records that are off by a day.
There is no substring fix for this, because the shift happens before your expression runs, and a function field has no timezone-conversion function. So change the approach instead of the expression: if you only need the calendar day, do not derive it from a Date/Time. Store it as a Date field, which has no time component to roll over, and populate it where approved_end_date is set — for example with a Business Rule using GlideDateTime, where new GlideDateTime(current.approved_end_date).getDate() gives you the date portion of the stored value. Or keep the function field but accept that it follows the system timezone, and compare its result against the date in the system timezone rather than your own.
The key point: fix the source value's type, not the string parsing — the parsing is doing exactly what it was told.
If this helped, please mark it as Helpful — and if it solved your issue, I'd be grateful if you accepted it as the solution.