Day() Function

YouTube: How to Use the Day Function in Report Custom Columns ?

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.

  • Before adding the expression to the report, go to Other Settings.

  • Ensure the Script Editor is set to VBScript.

  • 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

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

  • Fill in the required fields:

    • Expression Name – A unique name for your expression.

    • Expression Type – Choose either Text or Numeric depending on the expected output.

  • 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.

  • Click Save.

  • Scroll down and check the box to enable the column in the report.

  • Save and proceed to check the effect.

  • Refresh the report to view the final result.


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.

Last updated