---
title: Caclulate the Number of Days in a Period|Tutorial|BW Consultant Guide
description: Get step-by-step instructions on how to set up a variable that allows you determine the number of days in a period without using a user exit.  Written by our senior SAP BW HANA architect.
image: https://www.sapbwconsulting.com/hubfs/AI-Generated%20Media/Images/The%20image%20features%20a%20sleek%20modern%20workspace%20with%20a%20large%20computer%20monitor%20displaying%20a%20vibrant%20and%20detailed%20SAP%20BEX%20Query%20tutorial%20interface%20The%20screen%20is%20filled%20with%20colorful%20graphics%20diagrams%20and%20bullet%20points%20that%20outline%20the%20steps%20for%20calculating.png
---

# How to Calculate the Number of Days in a Period Using SAP BEX Query tutorial

## Do You Need to Know How to Calculate the Number of Days in a Period Using SAP BEX Query?

### Learn How In This [SAP BW Consulting](https://www.sapbwconsulting.com/hire-sap-business-intelligence-consultant) Tutorial

![Use OCALDAY to Calculate the Days in a Period](https://www.sapbwconsulting.com/hs-fs/hubfs/Stock%20images/Digitally%20generated%20binary%20code%20landscape%20on%20blue%20background.jpeg?width=1000&name=Digitally%20generated%20binary%20code%20landscape%20on%20blue%20background.jpeg "Use OCALDAY to Calculate the Days in a Period")

Many SAP customers spend vast amounts of money unnecessarily.

## How?  

By creating **user exits** when standard, out-of-the-box solutions exist from SAP.  One of the most common yet difficult tasks that many inexperienced [SAP BW](https://www.sapbwconsulting.com/blog/how-sap-certification-ought-to-work) consultants perform is setting up a variable to determine the number of days in a given period.   In our Tutorial **"How to Calculate the Number of Days in a Period"**, we show you:

- How to define and assign the **right variable**
- How to **avoid** using any **user exit** at all to do this task
- How to drastically **reduce the cost** of this task using **standard SAP Functionality**

Written a by one of our **Senior SAP Business Warehouse SAP HANA and SAP BOBJ Certified Architects**, this tutorial provides illustrated, step-by-step procedures used in a real life project.  If you would rather have it done for you, you can also just click on the link at the end of the tutorial and we can [help you](https://www.sapbwconsulting.com/blog/10-steps-to-developing-a-successful-business-intelligence-strategy) with that.

![SAP](https://googleads.g.doubleclick.net/pagead/viewthroughconversion/960101754/?value=0&guid=ON&script=0) 

![](https://www.facebook.com/tr?id=199270410761059&ev=PageView&noscript=1)

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period#webpage",
  "@type" : "WebPage",
  "about" : [ {
    "@type" : "Thing",
    "name" : "Variable",
    "sameAs" : "https://en.wikipedia.org/wiki/Variable_and_attribute_(research)"
  }, {
    "@type" : "Thing",
    "name" : "User",
    "sameAs" : "https://en.wikipedia.org/wiki/End_user"
  } ],
  "description" : "Learn how to calculate the number of days in a given period without relying on a user exit. Download our step-by-step tutorial.",
  "isPartOf" : {
    "@id" : "https://www.sapbwconsulting.com#website"
  },
  "mainEntity" : [ {
    "@id" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period#howto"
  }, {
    "@id" : "https://www.sapbwconsulting.com/about-lonnie-ayers#person"
  } ],
  "mentions" : [ {
    "@type" : "Thing",
    "name" : "Query",
    "sameAs" : "https://en.wikipedia.org/wiki/Web_query"
  }, {
    "@type" : "Thing",
    "name" : "Learning",
    "sameAs" : "https://en.wikipedia.org/wiki/Learning"
  }, {
    "@type" : "Thing",
    "name" : "Money",
    "sameAs" : "https://en.wikipedia.org/wiki/Money"
  }, {
    "@type" : "Thing",
    "name" : "Problem Solving",
    "sameAs" : "https://en.wikipedia.org/wiki/Problem_solving"
  }, {
    "@type" : "Thing",
    "name" : "Tutorial",
    "sameAs" : "https://en.wikipedia.org/wiki/Tutorial"
  }, {
    "@type" : "Thing",
    "name" : "Cost",
    "sameAs" : "https://en.wikipedia.org/wiki/Cost"
  }, {
    "@type" : "Thing",
    "name" : "Task",
    "sameAs" : "https://en.wikipedia.org/wiki/Task_(project_management)"
  } ],
  "name" : "How to Calculate the Number of Days in a Period Without Using a User Exit",
  "potentialAction" : {
    "@type" : "Action",
    "name" : "Download the Tutorial",
    "target" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period"
  },
  "subjectOf" : {
    "@id" : "https://www.sapbwconsulting.com/about-lonnie-ayers#offercatalog"
  },
  "url" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period#howto",
  "@type" : "HowTo",
  "author" : {
    "@id" : "https://www.sapbwconsulting.com/about-lonnie-ayers#person"
  },
  "description" : "This tutorial provides a detailed, step-by-step guide for calculating the number of days in a period without using a user exit in SAP BW.",
  "isPartOf" : {
    "@id" : "https://www.sapbwconsulting.com#website"
  },
  "mainEntityOfPage" : {
    "@id" : "https://www.sapbwconsulting.com/how-to-calculate-the-number-of-days-in-a-period#webpage"
  },
  "name" : "How to Calculate the Number of Days in a Period Without Using a User Exit",
  "step" : [ {
    "@type" : "HowToStep",
    "name" : "Define the period",
    "text" : "Identify the start and end dates for the period you want to calculate."
  }, {
    "@type" : "HowToStep",
    "name" : "Use a variable formula",
    "text" : "Implement a variable formula to calculate the difference between the start and end dates."
  }, {
    "@type" : "HowToStep",
    "name" : "Test the solution",
    "text" : "Run test queries to ensure the calculation produces accurate results."
  } ],
  "tool" : [ {
    "@type" : "HowToTool",
    "name" : "SAP BW System"
  }, {
    "@type" : "HowToTool",
    "name" : "Formula Builder"
  } ]
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com/about-lonnie-ayers#person",
  "@type" : "Person",
  "jobTitle" : "President",
  "name" : "Lonnie D. Ayers",
  "sameAs" : [ "https://www.linkedin.com/in/lonnieayers/", "https://twitter.com/Lonniea39" ],
  "url" : "https://www.sapbwconsulting.com/about-lonnie-ayers",
  "worksFor" : {
    "@id" : "https://www.sapbwconsulting.com#organization"
  }
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com#organization",
  "@type" : "Organization",
  "contactPoint" : {
    "@type" : "ContactPoint",
    "areaServed" : "Worldwide",
    "availableLanguage" : [ "English", "Spanish" ],
    "contactType" : "Customer Support",
    "telephone" : "+1-812-340-5581"
  },
  "logo" : "https://www.sapbwconsulting.com/hs-fs/hubfs/sapbw-consulting.png",
  "name" : "SAP BW Consulting, Inc.",
  "sameAs" : [ "https://www.linkedin.com/in/lonnieayers/", "https://twitter.com/Lonniea39", "https://www.facebook.com/SAPBWConsulting" ],
  "url" : "https://www.sapbwconsulting.com"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com#website",
  "@type" : "WebSite",
  "name" : "SAP BW Consulting, Inc.",
  "publisher" : {
    "@id" : "https://www.sapbwconsulting.com#organization"
  },
  "url" : "https://www.sapbwconsulting.com"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://www.sapbwconsulting.com/about-lonnie-ayers#offercatalog",
  "@type" : "OfferCatalog",
  "name" : "SAP BW Consulting Services Catalog",
  "url" : "https://www.sapbwconsulting.com/about-lonnie-ayers"
}
```