The TimeInterval derived property can be used to calculate the interval between two specified times. The feature is useful in situations in which you need to compute an unknown date or amount of time, or to calculate the length of time between two dates. For example, you could add a custom property called age to the user profile and use the time interval derived property to calculate its value by comparing the user’s date of birth to today’s date.

TimeInterval derived properties are readable and queryable. Note, however, that the feature does not support comparison queries on a derived property that is calculated using two date properties. See the second example at the end of this section.

The TimeInterval derived property is implemented by the property descriptor atg.repository.dp.TimeIntervalPropertyDescriptor, which uses the supporting derivation method atg.repository.dp.TimeInterval.

The interval is an integer that can be represented as follows:

int timeStampDiff(int interval, Date date1, Date date2)

where the integer is the number of intervals (which can be years, quarters, months, weeks, hours, days, minutes, seconds, milliseconds) by which date2 is greater than date1.

The derived property has three attributes, which are described below.

Attribute

Type

Required

Description

timeStampInterval

String

Yes

Represents the returning interval between the corresponding times. Must be one of year, quarter, month, week, day, hour, minute, second, or millisecond.

datePropertyName1

String

No

The name of the property to use as the date1 argument. Defaults to the current time if not specified.

datePropertyName2

String

No

The name of the property to use a the date2 argument. Defaults to the current time if not specified.

The following example shows how to configure the TimeInterval derived property in a GSA repository definition to calculate the age of a user:

<property name="age"
          data-type="int"
          writable="false"
          property-type="atg.repository.dp.TimeIntervalPropertyDescriptor">
   <attribute name="timeStampInterval" value="year"/>
   <attribute name="datePropertyName1" value="dateOfBirth"/>
</property>

The next example illustrates the use of the time interval derived property for computing the number of days between two date properties.

<property name="daysOfEmployment"
          data-type="int"
          writable="false"
          property-type="atg.repository.dp.TimeIntervalPropertyDescriptor">
   <attribute name="timeStampInterval" value="day"/>
   <attribute name="datePropertyName1" value="startDate"/>
   <attribute name="datePropertyName2" value="endDate"/>
</property>

Important: In some cases, time interval derived properties cannot be included in comparison queries. This restriction typically applies when the query involves a property derived from two dates, such as the daysOfEmployment example above. Queries that compare properties derived from two dates with another value (for example, “daysOfEmployment > 90”)are not supported in RQL.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices