Built-in Functions → quarterDay

quarterDay() is a conversion function that returns the count of days from the beginning of the quarter for a given date or timestamp.

Note

To return the quarter’s count of days for the current date, use the quarterDay() conversion function without a parameter.

Signature

quarterDay(date_timestamp exp)

The following table illustrates the quarterDay() function parameter:

ParameterDescription
date_timestamp expThe date or timestamp value to determine the quarter’s day number from

Returns

int representing the count of days of a quarter for a given date or timestamp.

Examples

  • Identify the day number of the quarter for the given date, 04/24/2020.
quarterDay(
date(
"2020-04-24"
)
)

The given date is April 24th. Thus, the quarterDay() of the second quarter (Q2: April, May, and June) is 24 since the quarter starts in April.

  • Identify the day number of the quarter for the given timestamp, 02/06/2021 03:09:11.
quarterDay(
timestamp(
"2021-02-06 03:09:11"
)
)

The given timestamp is February 6th 03:09:11 and January has 31 days. Thus, the quarterDay() of the first quarter (Q1: January, February, and March) is (31 + 6) = 37.

The following table illustrates the behavior of the quarterDay() conversion function:

ProductRevenuesquarterDay(date)quarterDay(timestamp)
CD$2002437
Hard disk$6002437
Cable$5502437
Hardware$8002437
Memory Card$2202437

Use the following steps for detailed instructions on how to use the quarterDay() conversion function to tackle the first example above in an insight:

Note

In the Cluster Management Console (CMC), create a tenant that includes Sample Data. The Sample Data includes the SALES schema.

  • In the Navigation bar, select the Content tab, and then select + New → Add Dashboard.
  • In the Add Dashboard dialog, for Name, enter Product Dashboard, and then select Add.
  • In the Action bar, select + (add icon), or select + Add Insight.
  • In the Insight panel, select Listing Table or V.
  • In Tables, select Aggregated Table.
  • In the Data panel, select Manage Dataset.
  • In the Manage Data Sets panel, in Tables, select SALES. Close the panel.
  • From the Data panel, drag and drop the following columns to the respective tray:
    • Category from the PRODUCTS table to the Grouping Dimension tray.
    • Revenue from the SALES table to the Measure tray.
      • In the Properties panel, for Number Format, select Dollar Rounded.
  • From the Data panel, drag and drop Add Formula to the Grouping Dimension tray.
  • The Formula Builder automatically opens:
    • Double-click the first quarter function, quarterDay(date_timestamp exp), to add the formula to the editor.
    • In the Formula Editor, replace date_timestamp exp with date("2020-04-24")
    • Select Validate & Save.
  • In the Properties panel, for Column Label, enter quarterDay().
  • Name the insight Revenue Per Category.
  • In the Action bar, select Save.