RelativeDate

Returns a text description of the DateTime supplied relative to now.

Use this function to get an estimated, easier to understand, description of when something happened (or will happen). For example, if you created an incident 13 days, 6 hours, 42 minutes, and 19 seconds ago, this function returns "2 weeks ago", because that is about 2 weeks ago.

Syntax

RelativeDate(dateTime, timeZone)

Enabled For

For a description of the business object categories, see Notes on "Enabled For".

Business Object Category Yes/No
Business Rules: Before-Save Rules Yes
Business Rules: Calculation Rules (After Save, with or without Also Recalculate on Load) Yes
Business Rules: Calculation Rules (Before Save or Always, without Also Recalculate On Load) Yes
Business Rules: Calculation Rules (Before Save or Always, with Recalculate On Load) Yes
Business Rules: Editing Rules Yes
Business Rules: Initialization Rules Yes
Business Rules: Read Only Rules Yes
Business Rules: Required Rules Yes
Business Rules: Validation Rules Yes
Client Expressions Yes
Object Permissions No
Services Yes
LDAP Yes
Mobile Yes
Quick Actions (except UI Quick Actions) Yes
UI Quick Actions Yes
Reports Yes
Search/Dashboard without field references Yes
Search/Dashboard with field references No

Parameters

Parameter Description

dateTime

A date and time.
timeZone

(Optional) The time zone, in IANA Internet Assigned Numbers Authority. The HEAT Service Management software UI identifies time zones as they appear in the IANA time zone database. format.

Return Value

Text value. One of the following, where n is a whole number:

now

n minute(s) ago

n hour(s) ago

yesterday

n day(s) ago

n week(s) ago

n month(s) ago

n year(s) ago

n minute(s) from now

n hour(s) from now

tomorrow

n day(s) from now

n week(s) from now

n month(s) from now

n year(s) from now

Example

RelativeDate(CreatedDate())

If the value of the CreatedDate() function is March 10, 2015 and today is March 27, 2015, this example returns "2 weeks ago" because March 10 is about 2 weeks before March 27.

If the value of the CreatedDate() function is September 10, 2014 and today is March 27, 2015, this example returns "6 months ago" because September 10, 2014 is about 6 months before March 27, 2015.

If the value of the CreatedDate() function is March 27, 2015 at 11:16am and today is March 27, 2015 at 11:15am, this example returns "now".

If the value of the CreatedDate() function is May 25, 2015 and today is March 27, 2015, this example returns "2 months from now" because May 25 is about 2 months away from March 27.