# Format() Function

**YouTube:** [How to Use the Format () Function in Report Custom Columns?](https://www.youtube.com/watch?v=Y-6-hia-8B8)

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

In this tutorial, we’ll explore how to use the **`Format` function** to customize the displays style of **dates** and **numbers** in your reports.

***

### 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="/files/QqZlgPb7nJy0O1lsvxB5" 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="/files/US8rZzar6siLdptkuOMX" 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="/files/K37bBe9AvTCKOiLXaocU" 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="/files/H9Z2PIgR9nQpQ8EWsn8t" alt=""><figcaption></figcaption></figure>

### Example 1: Format a Date (Bill Date)

* Double-click your newly created expression to insert it into the script editor.
* Define the expression using the syntax:
* Expression Name = FORMAT(CDATE(BILL\_DATE),"dd MMMMM yyyy")
  * `Format` Start your Expression with `Format` Keyword that is used to apply styles in Date & Text.
  * `CDate(BILL_DATE)` converts the value to a date.
  * `"dd-MMMM-yyyy"` is the desired date format.

<figure><img src="/files/CESgUsSXGb8LWJuao0aM" 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="/files/2xi7yCPlOQ8tUF2o6nuS" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/kqrKRBnqZemjUrdHpwWL" alt=""><figcaption></figcaption></figure>

* **Result**: Bill date will be shown like `09-June-2025`.

***

### Example 2: Format a Number (Rate with 2 Decimal Places)

* Click the (+) Plus icon to create a new expression.

<figure><img src="/files/01zqtIAH9JUwKy4jrZR5" alt=""><figcaption></figcaption></figure>

* Double-click your newly created expression to insert it into the script editor.
* Define the expression using the syntax:
  * Expression Name = FORMAT(RATE\_UNIT,"#0.00")
    * `RATE` is the numeric field name.
    * `"#0.00"` ensures **two decimal places**.

> To format with 4 decimal places: `Format(RATE, "#0.0000")`

<figure><img src="/files/4hOKVerisEJkGjqNcbKQ" 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="/files/iTXu7pUMQgEqM136eYBr" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/yfX57g1i4vGC69aPfan6" alt=""><figcaption></figcaption></figure>

**Result**: A rate like `123.5` will be shown as `123.50`.

***

### Summary

| Format Type | Example Expression                         | Output Example |
| ----------- | ------------------------------------------ | -------------- |
| Date        | `Format(CDate(BILL_DATE), "dd MM yyyy")`   | `30 06 2025`   |
| Date        | `Format(CDate(BILL_DATE), "dd MMMM yyyy")` | `30 June 2025` |
| Number      | `Format(RATE, "#0.00")`                    | `89.00`        |
| Number      | `Format(GROSS_AMT, "#0.000")`              | `1050.235`     |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/defining-custom-columns-in-reports-and-grids-with-expressions/format-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
