Skip to main content

Calculated Date Ranges

Using a calculated date range field and gremlin to return a date range automatically

Kristine Marhilevica avatar
Written by Kristine Marhilevica
Updated over 2 weeks ago

Please note: "Date time range" fields are no longer supported. If you have existing "Date time range" fields, please change it to "Date range" fields instead for the Gremlin query to be shown.

Please see this article on how to change the type of the field:
https://help.ardoq.com/en/articles/44183-add-and-manage-fields#renaming-and-changing-the-type-of-fields

1. Create a new field, and select Date range as the type

2. Select Gremlin query as the transformation

3. Input the query for the start date

//Example: get referenced component date fields 
//this gets the min value of the start dates

g.V(ids).where(__.in('Realizes').has('active_period_start_date')). project('id', 'name', 'value').
by(id).
by('name').
by(__.in('Realizes').has('active_period_start_date').order(). by('active_period_start_date', desc).limit(1).
values('active_period_start_date'))

4. Input the query for the end date

//Example: this one gets the max value of the end dates 
g.V(ids).where(__.in('Realizes').has('active_period_end_date')). project('id', 'name', 'value').
by(id).
by('name').
by(__.in('Realizes').has('active_period_end_date').order(). by('active_period_end_date', desc).limit(1). values('active_period_end_date'))

5. Apply and Save

Select the component types and/or reference types to apply this field to and Save.

Did this answer your question?