community postAL Developmentcommunity - not Microsoftreviewed - checked by Opus

Dynamics 365 Business Central: How to add or subtract hours from a DateTime field

Adding or subtracting hours from DateTime fields in Business Central can be done using the AddHoursToDateTime procedure from the Type Helper codeunit. This is useful for timezone conversions and date-time manipulations in AL code.

post Dynamics 365 Lab

Yun Zhu · 2026-01-21 · 269 words · about 1 min

"if you only need to add or subtract hours from a DateTime field, there's an even simpler method"

Key points

  • The Type Helper codeunit provides an AddHoursToDateTime procedure for simple hour arithmetic on DateTime fields
  • Pass positive values to add hours and negative values to subtract hours
  • This method is simpler than working with Duration data type when you only need to adjust hours
  • Timezone conversions can be achieved by adding or subtracting hours based on the offset between UTC and the target timezone

Quotes

  • “if you only need to add or subtract hours from a DateTime field, there’s an even simpler method” (Highlights that AddHoursToDateTime is a convenient alternative to Duration calculations for hour-only adjustments)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

No source states these links: they share an object, a model read them, or a person found the same subject.

Context

  • Features: DateTime manipulation, AddHoursToDateTime procedure, timezone conversion, Duration data type

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.