Months Dif From Now

The MonthsDifFromNow function calculates the number of full months between a given date and the current system date. It helps track the duration of time passed in months, especially useful in workflows involving installment plans, tenure-based validation, or reminders.

When to Use

Use the MonthDifFromNow function when you need to:

  • Calculate how many months have passed since a specific event.
  • Set up eligibility criteria based on monthly durations.
  • Trigger workflows based on the passage of time (e.g., payment due alerts, policy reviews).

This is particularly useful in banking and finance for managing customer commitments, loan schedules, and recurring reminders.

Common Use Cases

  • EMI Reminder Logic
    Trigger an alert if more than one month has passed since the last EMI payment.
  • Loan Review Eligibility
    Enable loan top-up options only after 6 months from the disbursal date.
  • Policy Expiry Tracking
    Check if more than 12 months have passed since policy issuance to allow renewal.
  • Recurring Deposit Maturity
    Track monthly progress on recurring deposit tenure.

Concept

You will typically use the function within the Smart Selector, which has various function tabs. By typing “MonthsDifFromNow” in the search bar, you can select it and define its parameters.

Parameters:

DatetimeThis defines the source date from which the function will calculate the difference in years compared to the current date.

You can enter:
A reference to an element (e.g., DatePicker_StartDate)

Or a JSON path to fetch a value from an entity (e.g., Insurance.policy[0].startDate)
FormatThis specifies the format of the date being read. The function uses this to correctly parse the input date before calculating the difference. DD, MM, YY, HH, SS, DDD, MMM, YYYY, etc.

Since this function can be applied across multiple scenarios to show year difference from the current year, we’ll walk through one specific example below:

Display the month difference between the current date and the date typed by the user in an input field.
Example Scenario: Check the total months that have passed since policy issuance.

Pre-Requisite:

  • Basic Understanding of Tasks.
  • A screen in vDesigner 2.0 with the following elements:
Element TypeElement NameReference NameDescription
Input FieldMonths Since PolicyInputField_monthdiffDisplays the total number of months elapsed since the policy start date.
ButtonCalculateButton_monthdiffTriggers the task to calculate the months between the current date and policy start date.

Now there are two ways to fetch the data:

  1. Define a Static Value and calculate from that.
  2. Fetch the value dynamically through the entity

Here, we are going to fetch it from Static Value:

After you drag an Input Field and a button to the vDesginer Canvas, you have to do only two steps:

  1. Creating a Task Group
  2. Linking of Task Group

Creating a Task Group

The task group defines what happens when user perform certain action:

  1. Drag Copy Data Task to the execution panel and do the following:
Copy FromCopy To
1. Select the MONTHSDIFFROMNOW function.

2. Define its Format (e.g., DDMMYYYY).

3. In the Datetime parameter, select the Static Function (e.g., InputField_FDMaturity).

4. Under the Static function:

– Define the policy starting date in DDMMYYYY format e.g. 23102024.
– Define its CastTo parameter as Datetime.
Select the element where you want to show the result of function. (e.g., InputField_monthdiff)
  1. Reload the elements.

Linking Task Group

Link the Task Group to the “Calculate” button using the OnClick event. This ensures that once the user clicks the button, the associated task is triggered.

Final Result

When the user clicks the “Calculate” button, the MONTHSDIFFROMNOW function will compute the total number of months that have passed since the policy’s start date and display the result in the designated input field.

Another Example Scenario:

In the same example explained above, you can also display a message if the policy has crossed 12 months of expiry by setting a Display Message task on the fulfillment of the condition defined under a business rule.

Message:

Business Rule:

Best Practices:

  • Use consistent date formats to ensure accurate parsing and calculation.
  • Validate user-entered dates using regex or format settings to prevent invalid input.
  • Reload entities when date values are updated during runtime to reflect the latest changes.
Was this article helpful?
YesNo