ServiceNow's date math centers on a critical choice: local time vs UTC. Most developers instinctively reach for addDays(), which is actually an alias for addDaysLocalTime() and handles daylight saving time transitions by adding 24-hour periods in the user's timezone. But when your business logic requires consistent calendar days regardless of DST shifts, addDaysUTC() is your safety net. The wrong choice will give you contract dates that shift an hour twice a year or SLA deadlines that land 23 or 25 hours later than expected.
When to use this
- Setting SLA due dates and escalation schedules in business rules where the user's local timezone matters
- Calculating review dates, reminder notifications, or follow-up tasks relative to today
- Determining contract expiration dates where consistent calendar arithmetic is required
- Computing business day calculations that need to exclude weekends and holidays
When NOT to use this
- Don't use this in client scripts — date math happens on the server; use
GlideAjaxto call a Script Include - Don't use
addDaysLocalTime()for financial calculations — useaddDaysUTC()to avoid DST inconsistencies - Don't loop through hundreds of records doing date math — move the calculation to a scheduled job or batch processor
- Don't add days to existing date fields without checking for null — use
gs.nil()to validate first
Key behaviors and gotchas
addDaysLocalTime()adds 24-hour periods respecting DST — during spring forward, adding 1 day might jump 25 hours of clock timeaddDaysUTC()ignores timezone and DST entirely — always adds exactly 24-hour periods to the underlying UTC timestampgetDayOfWeekLocalTime()returns integers 1-7 where 1 is Sunday and 7 is Saturday — not Monday-based like some systems- Date fields store timestamps in UTC but display in the user's timezone — your calculation method affects what the user sees
- Negative values work for subtracting days — use
addDaysLocalTime(-7)to go back one week - Creating a new
GlideDateTime(existingDate)copies the timestamp — essential when you need both original and calculated dates - Business day calculations require manual weekend detection — ServiceNow has no built-in business day calendar
Never assume addDays() and addDaysUTC() produce the same result. During DST transitions, they can differ by an hour, which breaks date-based queries and confuses users looking at the UI.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.