---
title: How to Calculate the Number of Days in the Selected Period for the Report (without using a customer exit!).
description: How to Calculate the Number of Days in a selected period for the report (avoid a customer exit!). Use SAP BW 0CalDay and replacement path variables
---

[SAP BW|BOBJ|Project Management Blog ](https://www.sapbwconsulting.com/blog)

# [How to Calculate the Number of Days in the Selected Period for the Report (without using a customer exit!).](https://www.sapbwconsulting.com/blog/how-to-calculate-the-number-of-days-in-the-selected-period-for-the-report-without-using-a-customer-exit)

 Written by [Victor Ayers](https://www.sapbwconsulting.com/blog/author/victor-ayers) | Wed, Mar, 20, 2013 @ 12:18 AM

## How To Avoid Using ABAP When Calculating The Number Of Days In A Selected Time Period

 

We frequently have questions regarding [calculating](https://www.sapbwconsulting.com/blog/inbound-marketing/how-to-correctly-calculate-conversion-rate-3-easy-formulas-to-use) the number of days in a selected period when using [SAP BW](https://www.sapbwconsulting.com/blog/understanding-the-most-common-sap-data-warehousing-concepts).  Many [SAP customers](https://www.sapbwconsulting.com/sap-partner-advisory-services), for a variety of reasons, take what we consider the tougher higher [risk](https://www.sapbwconsulting.com/sap-sem-cpm-risk-register-design-template), path.  Usually, this involves [developing a program used in a customer exit](https://www.sapbwconsulting.com/sap-bw-3.x-to-7.x-upgrade-service-productized-approach-proprietary-methodolgy). 

However, there is no need to do this most of the time and we wanted to share with you a quick and [simple solution](https://www.sapbwconsulting.com/blog/what-is-the-tco-of-that-shinny-new-system-youre-about-to-buy) to this common [SAP BW](https://www.sapbwconsulting.com/understanding-sap-bw-in-5-minutes) BEx Query Design problem.

### Here is a six step solution that you can use today to solve this common problem:

 

 1.  Create a new calculated [**Key Figure**](https://www.sapbwconsulting.com/blog/how-to-model-key-figures-sap-bw-tutorial)

2.  Create a new **[formula](https://www.sapbwconsulting.com/blog/how-to-determine-your-fully-loaded-cost-rate) variable**

 

3.  Make selections similar to what you see in this screen. We will **process by [replacement path](https://www.sapbwconsulting.com/develop-a-data-governance-framework)** and reference characteristic 0CALDAY.  0CALDAY is used in this report as the main date field and the user is prompted to enter a Date

**From and Date to in the same variable (a mandatory interval variable).**

 

4.  Go to the **Replacement Path** tab.  Here you will [enter the name](https://www.sapbwconsulting.com/blog/inbound-marketing/the-guaranteed-easiest-way-to-calculate-sla) of the [variable](https://www.sapbwconsulting.com/blog/how-to-get-the-webi-universe-data-source-connection-setup) used on 0CALDAY and define the “replace variable with” to ‘variable’. We also change the “Use Interval” to ‘Difference’. This will give us the difference between the two selected dates.

 

 

5.  Finally, use this newly created formula variable in the new calculated key figure.

 

 

6.  Now you can insert this [calculated key figure](https://www.sapbwconsulting.com/blog/how-to-model-key-figures-sap-bw-tutorial) into your report. You will get a column that repeats the result for each row. This can be handy for other [calculations](https://www.sapbwconsulting.com/fully-loaded-cost-calculator) such as calculating the number of available workdays in a period. (In our case, the user enters the number of [workdays](https://www.sapbwconsulting.com/consulting-rate-calculator-whats-your-rate) manually at the [report](https://www.sapbwconsulting.com/blog/5-kpi-design-best-practice-guidelines) prompt screen). Then we calculated the number of weeks times the number of workdays and used the result for our final [metric](https://www.sapbwconsulting.com/business-ratio-formulas-financial-formulas).    

 

 

If you would like to have a more in-depth [tutorial](https://www.sapbwconsulting.com/sap-training-courses) on this technique you can download it here.

 

 

Got other questions dealing with the ever present and always tricky date and time calculations required in a SAP BEx Query?  Drop your question in our comment box.  Know other ways to solve this problem, let us know in the comments below.

 

**People Who This Also Read:**

- [How 11149 Companies Fixed SAP BW DTP Errors](https://www.sapbwconsulting.com/blog/how-11149-companies-fixed-sap-bw-dtp-errors)
- [Guide To Maintaining SAP BW Datasources For Classification](https://www.sapbwconsulting.com/blog/guide-to-maintaining-sap-bw-datasources-for-classification)
- [Identifying Cause Of Data Load Error When Using A SAP BW DTP](https://www.sapbwconsulting.com/blog/identifying-cause-of-data-load-error-when-using-a-sap-bw-dtp)
- [How To Create A Complete Copy Of A SAP BW 7.3 Dataflow](https://www.sapbwconsulting.com/blog/how-to-create-a-complete-copy-of-a-sap-bw-7-3-dataflow)
- What are 2 [Primary Focus](https://www.sapbwconsulting.com/blog/what-are-2-primary-focus-areas-for-sap-airline-customers) Areas for SAP Airline Customers?
- Learn What is [Catch Weight Management](https://www.sapbwconsulting.com/blog/learn-what-is-catch-weight-management)
- Understanding [Embedded Systems](https://www.sapbwconsulting.com/blog/understanding-embedded-systems-vs-sap-hana) vs SAP HANA
- 3 Ways to [Design KPIs](https://www.sapbwconsulting.com/blog/3-ways-to-design-kpis-using-sap-solution-map-composer) Using SAP Solution Map Composer
- BusinessObjects [Explorer](https://www.sapbwconsulting.com/blog/businessobjects-explorer-best-practices) Best Practices

 

Thanks

 

[View full post](https://www.sapbwconsulting.com/blog/how-to-calculate-the-number-of-days-in-the-selected-period-for-the-report-without-using-a-customer-exit)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Victor Ayers"
  },
  "dateModified" : "2026-01-17T12:12:59.870Z",
  "datePublished" : "2013-03-20T00:18:00Z",
  "headline" : "How to Calculate the Number of Days in the Selected Period for the Report (without using a customer exit!).",
  "image" : {
    "@type" : "ImageObject",
    "height" : 577,
    "url" : "http://cdn2.hubspot.net/hub/118735/file-24516728-png/images/new_variable_creation.png",
    "width" : 579
  },
  "mainEntityOfPage" : "https://www.sapbwconsulting.com/blog/how-to-calculate-the-number-of-days-in-the-selected-period-for-the-report-without-using-a-customer-exit",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Blog of SAP BW Consulting - Business Intelligence, BOBJ, Big Data, Project Management and Staffing"
  }
}
```