Before You Begin
This tutorial shows you how to calculate the time duration between two date attributes in Oracle Analytics and add a column with the duration (age) to your dataset.
Background
Duration is the number of years, months, days, minutes, and seconds between two dates in dataset records. This tutorial shows you how to calculate duration between order date and ship date.
What Do You Need?
- Access to Oracle Analytics
- Download sample_order_lines2023.xlsx to your computer
Create a Dataset
In this section, you create a dataset to use for calculating duration.
- Sign in to Oracle Analytics.
- On the Home page, click Create, and then click Dataset.
- In Create Dataset, click Drop data file here or click to browse, select the sample_order_lines2023.xlsx file, and then click Open.
- In Create Dataset Table from sample_order_lines2023.xlsx, click OK.
Calculate Duration
In this section, you create the duration calculation using Order Date and Ship Date.
- Click the sample_order_lines2023 tab.
Description of the illustration order_ship_date_columns.png - Select the Order Date column, click Options
and select Calculate Duration.
- In Column Name, enter
Duration to Shipping
. - From the Time Difference list, select Since to calculate how many days since the order was placed.
- From the Relative to list, select Ship Date.
- From the Calculate in list, select Days.
Oracle Analytics adds a column named Duration to Shipping to the dataset.
Description of the illustration order_ship_date_duration.png - Click Add Step.
- Click Save
. In Save Dataset As, enter
order_to_shipping_duration
, and then click OK.
Create a Workbook
In this section, you create a workbook with visualizations that show how you could use the Duration to Shipping data element.
- Click Create Workbook. Close the Auto Insights panel.
- In the Data
pane, hold down the Ctrl key, select Product Sub Category, Quantity Ordered, Ship Mode, and Duration to Shipping. Drag the data elements to the canvas.
- Select Quantity Ordered in Values (X-Axis) and drag it to Values to switch places with Duration to Shipping.
Oracle Analytics creates a scatter visualization of the data elements with the Duration to Shipping on the X-Axis.
Description of the illustration days_qnty_psc.png - In the Data
pane, hold down the Ctrl key, select Product Sub Category, Quantity Ordered, Order Priority, and the Duration to Shipping. Drag the data elements to the canvas and release next to the existing visualization.
- Select Quantity Ordered in Values (X-Axis) and drag it to Values to switch places with Duration to Shipping.
Description of the illustration num_days_ship_prodsubcat.png - Click Save
. In Save Workbook, enter
Shipping Days
and click Save. - Click Go back.
Modify the Calculate Duration Step
- On the Home page, hover over the sample_order_lines_order_duration dataset, click Actions
and select Open.
- In the Preparation Script
pane, hover over Calculate Duration to Shipping and click Edit
.
- In Calculate Duration, select Hours from the Calculate in list. Click OK.
Description of the illustration calc_duration_hrs.png - Click Save
and click Go back
.
- On the Home page, hover over the Shipping Days workbook, click Actions
and select Open.
- Click Edit
. Close the Auto Insights panel.
- Click Refresh
to update the Duration to Shipping calculation to show the change to hours.
Description of the illustration wbk_duration_hrs.png
Learn More
Calculate Duration Using Dates in Oracle Analytics
G12406-01
September 2024
Learn how to calculate duration using dates in Oracle Analytics.
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government's use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.