2.5.1 Finding Difference Between Dates

The 'dateDiff()' function is used to find the difference between two dates in days/months/years.

dateDiff('d', fromDate, toDate); // days

dateDiff('m', fromDate, toDate); // months

dateDiff('yyyy', fromDate, toDate); // years

For example, if you have a table bound to a query which contains the date field 'Birth Date', you can create a formula field (in the data binding dialog) that calculates the age of this Birth Date in years by subtracting the birthday from the current date. The script of this formula field is shown below.

dateDiff('yyyy', field['Birth Date'], CALC.today())

<< 2.5 Useful Date Functions © 1996-2013 InetSoft Technology Corporation (v11.4) 2.5.2 Calculating a Past or Future Date >>