Fuego.Lang : Interval

The Interval component represents the length of time that occurs between two events. For example, if today is April 14 and a sale order will be due on April 24, then the interval is 10 days (the length of time between now and the order due date). The Interval component represents a number of years, months, days, hours, minutes, or seconds; the component does not represent actual dates. For this reason, the Interval component does not correct for differing time zones.

The Process Business Language (PBL) provides a special literal syntax to represent Interval objects in code. Interval literals are enclosed by single-quotes ('). They are formed by a sequence of fields, where each field is a number followed by a unit suffix. Examples:
	intervalTest = '15d' // Fifteen days
	intervalTest = '1h30m15s' // One hour, 30 minutes and 15 seconds
	intervalTest = '1Y4M3h' // One year, 4 months and 3 hours
      
Refer to the Process Business Language (PBL) Reference for a complete description of Interval literals.

When an Interval object is created from a literal expression, the values are normalized to fit the internal representation of the Interval component. Note the following details on how the Interval component normalizes time values:


Following are more examples of interval conversions:


Example 1

In the following example, a time interval is created using the difference between two dates:

now = 'now'
newYear = Time.valueOf(year : now.year+1, month : Month.JANUARY, day : 1)
timeUntilNewYear = newYear - now
display timeUntilNewYear	
      

Example 2

In the following example, a future date is calculated by adding an Interval to the current date:

	twoMonthsFromNow = 'now' + '2M'
      
Related reference
Fuego.Lang : Time