# Hour() Function

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

## How to Use the Hour() Function in Report Custom Columns?

In this tutorial, we will learn how to design an expression using the **`Hour`** function in the reporting grid. The `Hour` function is used to extract the **hour component** from a time or datetime field like **bill time**.

***

### Accessing the Expression Designer:

* Navigate to the **Reporting** section.
* Open the **Sales Register - Cross Tab 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%2Fy4opTLuRnFK6I7FmZAO8%2FAdd%20New%20Report.png?alt=media&#x26;token=d245d1e8-d86c-420c-b579-f66ac5d89a69" alt=""><figcaption></figcaption></figure>

### Creating a Simple Hour() Expression

* Double-click your newly created expression to insert it into the script editor.
* Define the expression using the syntax:
  * Expression Name = HOUR(CDATE(BILL\_TIME))
  * This expression extracts the **hour part** from the **bill time**.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F701DKpRzpjs6LwlCQ9kA%2FExpression%20Formula.png?alt=media&#x26;token=cfae9f2c-99a1-484a-b226-41f461400ad5" alt=""><figcaption></figcaption></figure>

* Save the expression once defined.
* Scroll down and **check the box** beside the expression name to enable it.

<figure><img src="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FfxVdvcYGJNUCmrPwd185%2FSetup%20Column%20Attribute.png?alt=media&#x26;token=623685a5-b02c-402c-99fe-c2a0f552c493" 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%2Fc97DwyYUxBJO4adTD2Kz%2FImp-Sale.png?alt=media&#x26;token=45680030-f270-469d-8c3f-bb2d1d39620f" alt=""><figcaption></figcaption></figure>

***

### Result:

The new column will now display the **hour** extracted from the `BILL_TIME` field.

> Example: If `BILL_TIME = 14:32:00`, then output = `14`.
