Script illistration - incident.age.days SummaryThe script "incident.age.days" is calculating the age of an incident in days, based on when it was opened (current.opened_at) and a specified end time (score_end). Code Breakdown var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();}; This function calculates the difference in milliseconds between two dates, y and x.dateNumericValue() is a GlideDateTime method in ServiceNow that returns the date's numeric value in milliseconds since the Unix epoch (January 1, 1970).The difference is obtained by subtracting x.dateNumericValue() (the earlier date) from y.dateNumericValue() (the later date). var days=function(x,y){return diff(x,y)/(24*60*60*1000);}; This function calculates the difference between two dates in days by: Calling the diff function to get the difference in milliseconds. Dividing the result by (24*60*60*1000), the number of milliseconds in a day, to convert milliseconds into days. days(current.opened_at, score_end); The days function is called with: current.opened_at: The date and time when the incident was opened. score_end: A reference date and time (likely the current time or a specific timestamp set in the context of the script).It calculates how many days have passed from current.opened_at to score_end. Example current.opened_at = 2025-01-01 08:00:00 score_end = 2025-01-03 08:00:00 diff(current.opened_at, score_end) computes the difference in milliseconds: score_end.dateNumericValue() - current.opened_at.dateNumericValue() (3 days in milliseconds) = 259,200,000 ms. days(current.opened_at, score_end) divides by the number of milliseconds in a day: 259,200,000 / (24*60*60*1000) = 3 days. Result The output is 3, indicating the incident has been open for 3 days as of the score_end date.