Built-in Functions → addQuarters

addQuarters() is a scalar date function that returns an updated date or an updated timestamp after adding the number of quarters as specified for the increment.

Signature

addQuarters(date_timestamp exp, int quarters)

The following table illustrates the addQuarters() function parameters:

ParameterDescription
date_timestamp expThe date or timestamp value to which the quarters are being added
int quartersAn integer representing the number of quarters to add

Returns

Date or timestamp representing the updated time or timestamp after appending to the given quarter

Examples

  • Add 1 quarter to the date value, 05/02/2010.

    addQuarters(
    date(
    "2010-05-02"
    ),
    1
    )
  • Add 2 quarters to the timestamp value, 05/02/2010 03:09:11.

    addQuarters(
    timestamp(
    "2010-05-02 03:09:11"
    ),
    2
    )

Use the following steps for detailed instructions on how to use the addQuarters() function to create the above query:

Note

In the Cluster Management Console (CMC), you can 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 Add Data Set (+).
  • 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:
    • Revenue from the SALES table to the Measure tray.
    • Category from the PRODUCTS table to the Grouping Dimension tray.
  • From the Data panel, drag and drop Add Formula to the Grouping Dimension tray.
  • The Formula Builder automatically opens:
    • In Search Functions, select the down arrow, and then select Date Functions.
    • Double-click the addQuarters function, addQuarters(date_timestamp exp, int quarters), to add the formula to the editor.
    • In the Formula Editor,
      • Replace date_timestamp exp with date("2010-05-02")
      • Replace int quarters with 1
addQuarters(date("2010-05-02"), 1)
  • Select Validate & Save.
  • In the Properties panel, for Column Label, enter addQuarters() date
  • From the Data panel, drag and drop Add Formula to the Grouping Dimension tray.
  • In Search Functions, select the down arrow, and then select Date Functions.
    • Double-click the addQuarters function, addQuarters(date_timestamp exp, int quarters)
    • In the Formula Editor,
      • Replace date_timestamp exp with timestamp("2010-05-02 03:09:11")
      • Replace int quarters with 2
addQuarters(timestamp("2010-05-02 03:09:11"), 2)
  • Select Validate & Save.
  • In the Properties panel, for Column Label, enter addQuarters() timestamp
  • Name the insight addQuarters()
  • In the Action bar, select Save.