Allowed functions
The following is a list of functions that report designers can use in expression, selectConditions, conditions and possibly other property definitions of the JavaScript slicer dynamic data definition object.
Now()
Returns the current date and time.
DateAdd (periodType, date, number)
Adds a defined number of periods to a date.
periodType [string] options:
- y = year
- M = month
- w = week
- d = day
- h = hour
- m = minute
- s = second
- ms = millisecond
date [date or date string] is a date to add to.
number [integer] is the number of period to add (or subtract if it is a negative integer)
DateDiff (periodType, start, end, completePeriodsOnly)
Returns a number representing the number of periods that fit between the start and end dates.
periodType [string] is the same as in the DateAdd function.
start and end [date or date string] are the two limit dates between which we want to know the number of periods.
completePeriodsOnly [boolean] If true it will return the number of full periods that fit between the limit dates. If false (default), common rounding will be applied.
GetDate (date, adjustForTimezone)
Converts a date string a an actual date object.
date is the actual date string to convert. These can be in the ISO format as well or a Unix date integer.
adjustForTimezone will adjust the date to the current time zone. This can be used if the source string is in a UTC format but the actual date/time needs to be presented for the current time zone.
FormatDate (date, format, adjustForTimezone)
Formats a date object to a string of a defined format.
date [date or date string] is the date to be formatted. It can be a date object or date string, in which case the GetDate() function described above is used internally to convert it to a date object first.
format [string] is a format to be used like ‘d MMM yy H:mm’ which will result in a date string like: ‘9 Jan 24 6:58’ if the passed-in date is ‘9 January 2024, 6:58:33.254 AM’.
The formatting options are:
d, dd, ddd or dddd for the day to be displayed as ‘9’, ‘09’, ‘Sat’ or ‘Saturday’
MM, MMM or MMMM for the month to be displayed as ‘Ja’, ‘Jan’ or ‘January’
yy or yyyy for the year to be displayed as ‘24’ or 2024
h, hh, H or HH for the hour to be shown as ‘6’, ‘06’, ‘6’ or ‘06’ for 6 AM and ‘4’, ‘04’, ‘16’ or ‘16’ for 4 PM.
mm for the minutes to be shown as ‘58’
ss for the seconds to be shown as ‘33’
nnn or sss for the milliseconds to be shown as ‘254’ or ‘25’
t or tt for the AM/PM time to be shown as ‘A’ or ‘AM’
FY (getEnd, date)
Returns the start or end of the financial year to which the date belongs to.
getEnd If true this will result in returning the last day of the financial year. If false or omitted it will return the first day of the financial year.
date is the date we want to find a financial year for.
CY (getEnd, date)
Returns the first or last day of the current year.
getEnd If true this will result in returning the last day of the current year which will always be 31 December. If false or omitted it will return the first day of the year will be returned, which will always be 1 January.
date is the date we want to find a current year for.
Year (date)
Returns an integer representing the date’s year.
Month (date)
Returns an integer representing the date’s month.
Day (date)
Returns an integer representing the date’s day.
GetMonthsSinceStartOfFinancialYear (includeCurrentUnfinishedMonth, orMin, date, reverseOrder)
Returns and integer representing the number of months that has passed since the start of financial year.
includeCurrentUnfinishedMonth Set to true if the current unfinished month should be included in the count.
orMin If specified than the count will start from the start of the previous financial year if the number of months since the start of the current financial year is less then this number.
date An optional date to which to count the months. If omitted the current date is automatically used.
reverseOrder Will reverse the order of the dates in the resulting array, going from the youngest to the oldest.
DatePeriods (parameterObject)
This is a generative function which generates an array of date periods.
Since this function has too many possible input parameters and its combinations a parameter object is used instead to specify the required combination of these parameters.
The parameterObject properties
periodType The type of the period to generate. The options here are the same as for the DateAdd function described also in this document.
step Specifies the number of steps to take for each following date generated. Can be a negative integer if each next date should be smaller as opposed to higher than the last.
startDate The start date from which to start generating the values. Can be omitted if at least the endDate is specified.
endDate The end date past which the generated dates should not reach. Can be omitted if at least the startDate is specified.
reverseOrder Set to true if you wish to have the dates generated in reverse order. This property may be useful if you only can specify the start or end date, but not both.
periods Lets you specify the maximum number of periods to generate. This parameter is compulsory if only one of the limit dates (start or end) is specified. It can be a negative number if the date sequence should go down instead of up from the current or passed-in date. If this value is negative it is the same as having a negative step value. However, do not combine negative value in periods with a negative value in step!!!
includeCurrentPeriod If true then the current unfinished period will be included in the list of generated dates.
resetTime If true (default) than the time will be set to 00:00:00. If false the current time at the time of this function call will be kept.
day Lets you specify a concrete day in a month in the generated dates.
month Lets you specify a concrete month in a year in the generated dates.
year Lets you specify a concrete year in the generated dates.
hour Lets you specify a concrete hour in the generated dates.
minute Lets you specify a concrete minute in the generated dates.
second Lets you specify a concrete second in the generated dates.
GetNthMember(array, index)
Returns a single value from an array found at index passed in the second parameter.
array Any array of values from which a single value will be selected.
index The index of the array item to be returned. Can be a negative value in which case the actual index is counted from the end of the array.