Get Datamart Time Dimension from a Date

A Datamart stores time dimensions (week, month, quarter and year) for the pricing dates. To get a time dimension value, a DMCalendar instance (Datamart Calendar) can be used.

For example, the date "2018-01-24" falls in the week "2018-W04"; which can be retrieved by the getWeek(date) method of a DMCalendar instance:

def date = api.parseDate("yyyy-MM-dd", "2018-01-24") def week = api.getDatamartContext().calendar().getWeek(date) return week

Similarly, other time dimensions such as Month, Quarter and Year can be retrieved by getMonth(date), getQuarter(date) and getYear(date) methods respectively.

These functions (getWeek(), ...) always return values from Gregorian calendar and are always formatted in the default way. In other words, these functions do NOT use data from the cal Data Source. If you need the actual data from the cal table, you need to make a query to that Data Source.

Found an issue in documentation? Write to us.