(Tips & Tricks) Laserfiche Forms Month Formatting


Laserfiche Forms Month Formatting


A field may be required to display the month in a special format other than the typical date values provided by Laserfiche Forms. We will take advantage of the Function feature in Laserfiche Forms to format the month into a value that is not normally displayed. Four formatting methods will be used in this example:

  • Numeric Month

  • Zero Padded Numeric Month

  • Abbreviated Month Name

  • Full Month Name

A sample of the example can be downloaded here.

This example will be performed in the Laserfiche Forms Layout Designer and will require a creation of fields.

Date Field

The first field that must be created is a Date field. The formatting will not be executed correctly unless a date value is evaluated. Add a Date field in the canvas with the label of “Date” and the variable name of “DateField”.

Numeric Month Value with No Padding

The MONTH function returns the numeric value of a month when evaluating a date. For example, a date of February 19, 2020 will return the value of 2.


Add a Single Line text field to the canvas with a label name of “Month (M)” and variable name of “Formatted Month No Padding”.


Then select the Advanced tab of the field and use the following function:

=MONTH(DateField)
 

The “DateField” in the parenthesis would be the variable name of the date field created in the first section.


The result of this function will be the numeric value of the Month when a date is selected in the Date field.

Numeric Month Value Zero Padded

The Month function returns a non-padded numeric value. There may be use cases where a zero padded numeric month value is needed. Adding a zero in front of a single digit month will require the introduction of the CONCATENATE and RIGHT functions. The CONCATENATE function combines values together in the sequence they are defined in the function. The RIGHT function returns a set of characters from the right based on the number specified in the function.

Add a Single Line text field to the canvas with a label name of “Month (MM)” and variable name of “Formatted Month Zero Padded”.


Then select the Advanced tab of the field and use the following function:

=RIGHT(CONCATENATE("0", MONTH(DateField)), 2) 

The “DateField” in the parenthesis would be the variable name of the date field created in the first section.


Working with the functions "in to out"…. The MONTH function returns the numeric value of the date. The CONCATENATE function will place a zero (“0”) in front of the returned MONTH value. The RIGHT function will take the last 2 characters of the concatenated value from the right. For double digit months such as October, the CONCATENATE function will return “010” which will then require the RIGHT function to remove the extra zero on the left.

Abbreviated Month Name

A requirement might be to return an abbreviated month value from a selected Date field. The CHOOSE function will be introduced to accommodate the use case.


Add a Single Line text field to the canvas with a label name of “Month (MMM)” and variable name of “Formatted Month Abr”.


Then select the Advanced tab of the field and use the following function:

=CHOOSE(MONTH(DateField), "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec

The CHOOSE function acts a selector in which it returns the value at the index provided in the first argument. The subsequent arguments, in this case, will be the abbreviated month values. The MONTH function will act as the numeric index (starting with 1) to return the correct abbreviated month.

Full Month Name

Like the Abbreviated Month section, the Full Month Name can be returned by using a combination of the MONTH and CHOOSE functions.

Add a Single Line text field to the canvas with a label name of “Month (MMMM)” and variable name of “Formatted Month”.


Then select the Advanced tab of the field and use the following function:

=CHOOSE(MONTH(DateField), "January","February","March","April","May","June","July","August","September","October","November","December"

The CHOOSE function acts a selector in which it returns the value at the index provided in the first argument. The subsequent arguments, in this case, will be the full month name values. The MONTH function will act as the numeric index (starting with 1) to return the correct month name.


Complete Paperless Solutions

5130 East La Palma Avenue, #206

Anaheim, California  92807

Email info@cps247.com

Telephone (866) 661-2425

©2020 by Complete Paperless Solutions