Built-in Functions → quarter
quarter() is a conversion function that returns the quarter number for a given date or timestamp.
Note
To return the quarter number for the current quarter, use this quarter() conversion function.
Signature
quarter(date_timestamp exp)
| Parameter | Description | 
|---|---|
| date_timestamp exp | The date or timestamp value to determine the quarter number from | 
Returns
int representing the number of the quarter. 
Examples
- Identify the quarter number for the given date, 04/20/2020.
 
quarter(date("2020-04-20"))
- Identify the quarter number for the given timestamp, 01/01/2021 03:09:11.
 
quarter(timestamp("2021-01-01 03:09:11"))
The following table illustrates the behavior of the quarter() conversion function:
| Product | Revenues | quarter(date) | quarter(timestamp) | 
|---|---|---|---|
| CD | $200 | 2 | 1 | 
| Hard disk | $600 | 2 | 1 | 
| Cable | $550 | 2 | 1 | 
Use the following steps for detailed instructions on how to use the quarter() conversion function:
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:
- In Search Functions, select the down arrow, and then select Conversion Functions.
 - Double-click the first quarter function, 
quarter(date_timestamp exp), to add the formula to the editor. - In the Formula Editor, replace 
date_timestamp expwithdate("2020-04-20") - Select Validate & Save.
 - In the Properties panel, for Column Label, enter quarter().
 
 - Name the insight Revenue Per Category.
 - In the Action bar, select Save.
 
