How can you calculate a future date and format time in 12-hour (AM/PM) format in an Apsona mail merge?

Apsona supports dynamic date calculations and time formatting directly within reports and merge templates using JavaScript-based expressions and format specifiers, without needing an existing field.

To calculate today’s date plus 7 days, you can use:

(new Date()).addDays(7)

For a formatted output:

(new Date()).addDays(7).format("MM/dd/yyyy")

To convert time values from 24-hour format to 12-hour format (AM/PM), you can use the .format("h:mm a") pattern.

This can be applied in two ways:

  • As a calculated field in a report using .format("h:mm a")

  • Directly in the merge template using:

«Event Start Time@h:mm a»

This ensures values like 15:00 are displayed as 3:00 PM.

Apsona allows flexible handling of date calculations and formatting, so you can compute future dates dynamically and control display formats either at the report level or directly within merge templates.