When calculating the difference between two date fields or formatting a date to display in a specific format, there are two parts to consider and include “Parameterization”: Left-Hand Side: This includes the function and fields you wish to evaluate. For example: Calculate 'Minutes': minutes_between(Specimen.customFields.additional_specimen_detail_form.cold_ischemia_end, Specimen.customFields.additional_specimen_detail_form.cold_ischemia_start) To format a date: date_format(Participant.regDate, "%month_day% %month3% %year4%") Right-Hand Side: This represents the condition to check against. Examples include: any > 20 <= 50 18 Jan 2017 (when using date format) Function Description months_between To find the number of months between two dates. Example: month between registration date and visit date minutes_between To find the number of minutes between two timestamp fields. Example: time difference between frozen and received time years_between To find the number of years between two dates. Example: age at collectionThese functions can be used as below as well
a) Days = minutes_between(d1, d2) / (24 * 60)
b) Hours = minutes_between(d1, d2) / 60
c) Weeks = minutes_between(d1, d2) / (7 * 24 * 60) current_date() To get current date. Example: age as of today round() To round up calculations. In cases where integer values are expected, for example, temporal expressions related to dates, round() function ensures that stable integer results are obtained.
Usage: round(expression, x)
Here, the expression is the integer value result that is to be rounded. 'x' is the number of decimal places to be rounded up to or the number of digits after the decimal point that the expression should be rounded to.Example: round( years_between( current_date(), Participant.dateOfBirth), 0) any will keep 0 digits after decimal. date_range(date, range_type, [interval]) Allows to check for data that falls in the particular date range. date: can be any form field or arithmetic expression whose result is of date type range_type: possible values are last_cal_qtr: last calendar quarter next_cal_qtr: next calendar quarter (new in v6.1) last_qtr: last quarter next_qtr: next quarter (new in v6.1) last_cal_month: last calendar month next_cal_month: next calendar month (new in v6.1) last_month: last month next_month: next month (new in v6.1) last_week: last calendar week (new in v4.0) next_week: next calendar week (new in v6.1) current_week: this week (new in v4.0) last_days: last N calendar days (new in v4.0) next_days: next N calendar days (new in v6.1) yesterday: yesterday's calendar date. Special form of last_days where N = 1 tomorrow: tomorrow's calendar date. Special form of next_days where N = 1 (new in v6.1) today: today's calendar date (new in v4.0) interval: a positive integer. Optional. When not specified, its value is assumed as 1 Date Range Temporal Filters Illustration: Assuming the present date as 15th March 2017 Expression Description Date Range date_range(Specimen.createdOn, last_cal_qtr, 2) Specimens created in last 2 calendar quarters 1st July 2016 00:00 to 31st December 2016 23:59 date_range(Specimen.createdOn, last_qtr, 2) Specimens created in last 2 quarters 1st September 2016 00:00 to 28th February 2017 23:59 date_range(Specimen.createdOn, last_cal_month, 3) Specimens created in last 3 calendar months 1st December 2016 00:00 to 28th February 2017 23:59 date_range(Specimen.createdOn, last_month, 3) Specimens created in last 3 months 15th December 2016 00:00 to 14th March 2017 23:59 date_range(Participant.regDate, today) Participants registered today 15th March 2017 00:00 to 15th March 2017 23:59 date_range(Participant.regDate, yesterday) Participants registered yesterday 14th March 2017 00:00 to 14th March 2017 23:59 date_range(Participant.regDate, last_days, 10) Participants registered in last 10 days 5th March 2017 00:00 to 14th March 2017 23:59 date_range(Participant.regDate, current_week) Participants registered in current week that is from ‘Sunday to Saturday'. If a query is run in the middle of the week, it will give results from 'Sunday to the current day’. 12th March 2017 00:00 to 18th March 2017 23:59 date_range(Participant.regDate, last_week, 2) Participants registered in last 2 weeks 26th February 2017 00:00 to 11th March 2017 23:59 date_format(date_expr, format) Outputs date/time field/expression value in desired format. date_expr: Any valid AQL expression that yields date/time type result format: Format of the output string and can be made up of following format specifier tokens. Values in examples of below table are given w.r.t date/time 18th January 2017 16:45:33 date_format(Participant.regDate, "%month_day% %month3% %year4%") > "18 Jan 2017" Only those participants registered after 18 JAN 2017 will be displayed in the desired format. Similarly, you can use the other operators like < , = etc Specifier Description Example %year4% Four digit year 2017 %year2% Two digit year 17 %month2% Two digit month 01 %month3% Three character abbreviation of month name Jan %month% Month name string January %month_day% Two digit day of month 18 %hour% Hour of the day in 24 hour format 00-23 16 %hour12% Hour of the day in 12 hour format 01-12 04 %minute% Minute of the hour 45 %second% Seconds of the minute 33 %meridian% AM or PM PM
Regarding the temporal function date range(), is last_day a possible value? I would like to create a temporal query using the Created On attribute for parent specimens, to display the parent specimens created on the current day of the query (today).