Font Size:
Ask Joget AI

Compare Date Column Value with Current Date

Introduction

Comparing date values with the current date is a common requirement for many applications. Whether you need to calculate age from a date of birth or determine the time elapsed since a specific date, you can achieve this by using a Bean Shell Formatter in Joget. This technique allows you to perform date calculations and display the results directly in your list columns.

How does it work?

The Bean Shell Formatter allows you to manipulate and format date values within your columns. By using the provided script, you can calculate differences between dates and format the output to display age or elapsed time.

  1. In the List Builder, go to the Date of Birth column and set the Formatter as BeanShell.
  2. Below is a sample BeanShell Formatter script used to calculate age based on a date of birth. Paste the following code into the Script section:
    import java.text.ParseException;
    import java.time.LocalDate;
    import java.time.Period;
     
    try {
        LocalDate birthDate = LocalDate.parse(value);
        LocalDate currentDate = LocalDate.now();
         
        Period dateDiff = Period.between(birthDate, currentDate);
         
        return dateDiff.getYears() + " YEAR(s) & " + dateDiff.getMonths() + " MONTH(s)";
    } catch (ParseException e) {
        e.printStackTrace();
    }

  3. Save the changes. 

Expected Outcome

When you set the Date of Birth field and submit the form, the system will automatically calculate the age by comparing the selected date with the current date. The result will then be displayed in the list in terms of years and months.

For example, if the Date of Birth is set to 1 January 2016.

In the list, the calculated age will be shown in years and months based on the current date.

Download Sample App

Download the demo app for Compare Date Column Value with Current Date:
Created by Julieth Last modified by Debanraj Ravindran on Apr 24, 2026