The quarter function returns the first month of the corresponding quarter of the date attribute. The results will always be:
1, if the date attribute is in the first quarter, from January to March:
4, if the date attribute is in the second quarter, from April to June;
7, if the date attribute is in the third quarter, from July to September;
10, if the date attribute is in the fourth quarter, from October to December.
If the extract parameter is True, the corresponding quarter is displayed.
The date, week, month, quarter or datetime attribute if the extract parameter is False to retrieve the month value.
If the extract parameter is True, all attribute types can be used. The date parameter is mandatory.
A binary value (True/False) which is set as False as default.
If True, the function returns the corresponding quarter.
The following example uses the Instagram_data dataset.
In this example, we want to retrieve the quarter of the Date Posted attribute. We want to be displayed the first month of the date’s corresponding order, so the formula will be:
The results can be read as follows:
In the following examples, you will see how the extract parameter changes the results.
In this example, we want to retrieve the quarter of the Date Posted attribute. As we want the exact quarter, and not its first month, we need to specify the extract parameter as True.
Add a new attribute, called quarter, and type the following formula:
This function returns completely different results when working using attributes whose type is different from those specified in the date parameter’s description:
In this use case, the starting date from which the function calculates the quarter is the default Rulex date, which is 1899-12-30, in order to return the corresponding date.
In this example, we want to retrieve the quarter of the Month attribute.
As its type is integer, the function must contain also the extract parameter.
Add a new attribute and type the following formula:
As you can see, the function has returned values in quarter format.
The Month attribute’s values are considered as the number of days to add to the default Rulex date, 1899-12-30: