# 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="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%2FJWIh0pvrEHd12AroIrCe%2FAdd%20New%20Expression.png?alt=media&#x26;token=0402f75e-653a-4529-b3ff-45d091922bc0" 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="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2F1ENFBZBM6EjCtIv6BZwi%2FEx%201%20-%20Expression%20Formula.png?alt=media&#x26;token=5d2a4f24-1a81-4ee5-940b-a58dc1d157cf" 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%2Flza4Hftvl5eZeGG9BdlW%2FSetup%20Column%20Attribute.png?alt=media&#x26;token=5586be36-0363-4087-85be-e7a4d43efabb" 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%2FczVMhkhLEVDynI3xF3nq%2FDate%20Rep_Imp.png?alt=media&#x26;token=1394bd91-a874-43d6-b723-f2fe406c7c0a" 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="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FfWnLgvATxhRbRJlSWkP9%2FEx%202%20Expression%20Formula.png?alt=media&#x26;token=8e4fa901-9ba3-408e-a53e-794d5e66b645" 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="https://4031188996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXMVkjt8zqHBQX1c9QvFS%2Fuploads%2FM3wo5TjZ1x4RsmQ6TH57%2FRate%20Exp%20Formula.png?alt=media&#x26;token=4e19522a-9904-4f10-a05b-3575a101610e" 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%2FTCHhprRgsQyGx1484Ei5%2FSetup%20Column%20Attribute%202.png?alt=media&#x26;token=973afa18-3145-4b72-ba36-817a7eb5fc22" 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%2FRM5OYI5v8jwdUNh85oPd%2FRate%20Rep_Imp.png?alt=media&#x26;token=20ecaac5-01b4-425b-b804-362d04a67ce9" 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`     |
