# Day() Function

**YouTube:** [How to Use the Day Function in Report Custom Columns ?](https://www.youtube.com/watch?v=5-oonlBNFX8)

## How to Use the Day Function in Report Custom Columns?

In this tutorial, we’ll learn how to use the `Day` function in expression design to extract the **day number** (e.g., 1 to 31) from a date field such as *Bill Date* within a report.

***

### Accessing the Expression Designer:

* Navigate to the **Reporting** section.
* Open the **Sales Register Detailed Report** or any **"Report".**
* Go to **Setup Column Attributes**.
* Here, you'll see a list of available columns that can be used to build expressions.
* Click on **"Add/Edit Expression Columns"** where you can write your expression using predefined functions.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FBiD7B0nHi6iarn4CKfDv%2FBill%20Setup%20column%20attribute.png?alt=media&#x26;token=a582faef-5c69-4eb5-ac56-48057aaab80b" alt=""><figcaption></figcaption></figure>

* Before adding the expression to the report, go to **Other Settings**.
* Ensure the **Script Editor** is set to **VBScript**.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FPgRPBYdOmbcuIH0PZ7sI%2FOther%20Setting%20-%20VB%20Print.png?alt=media&#x26;token=60981fe7-c38c-4bf4-a8d9-40a3289ddbd7" alt=""><figcaption></figcaption></figure>

* Click **Save**.
  * *Note: VBScript is the default for new configurations but always verify this setting.*

### Writing Your First Expression

* Every expression must start with the script header: **'#@LSCRIPT**

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F6sCEhRlGWfBL2O3Tg0XY%2FBill%20Setup%20column%20attribute%20Default%20Script.png?alt=media&#x26;token=af5f02ec-c5a6-41e5-bf23-16e2265b02e7" alt=""><figcaption></figcaption></figure>

* Click the (+) Plus icon to create a new expression.
* Fill in the required fields:&#x20;
  * **Expression Name** – A unique name for your expression.
  * **Expression Type** – Choose either **Text** or **Numeric** depending on the expected output.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F3jiroDpSRv5FiIZTLuJU%2FAdd%20new%20expression%20-%20Report.png?alt=media&#x26;token=d1b6f7d0-f0b7-400c-b7ab-1f3861f21277" alt=""><figcaption></figcaption></figure>

* Double-click the new expression name to insert it into the script editor.
* Define the expression using the syntax:
  * **Expression Name** = DAY(CDATE(BILL\_DATE))
    * `Day(...)` returns the day component from the date (e.g., 5 for 5th June).
    * `CDate(BILL_DATE)` converts the string into a valid date.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F1XpjyhnVa6KFgqxQrsNV%2FNew%20Formula.png?alt=media&#x26;token=0b7ff206-14fc-47d6-87ae-9e80f909818c" alt=""><figcaption></figcaption></figure>

* Click **Save**.
* Scroll down and **check the box** to enable the column in the report.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FgLjLTxAHyeEaYs7CbZWL%2FSetup%20Column%20Attribute.png?alt=media&#x26;token=1285b776-530d-412c-b25c-1c997fc8b581" alt=""><figcaption></figcaption></figure>

* Save and proceed to check the effect.
* **Refresh the report** to view the final result.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FpbFEW6HWgE7ee1FWDB4l%2FImp_Sale.png?alt=media&#x26;token=54c705d5-7077-4a86-ba3d-1e6c940b31f8" alt=""><figcaption></figcaption></figure>

***

### Output:

The newly added column now displays the **day number** extracted from the *Bill Date*.\
For example: if the bill date is `09-Jun-2025`, the output will be `9`.
