Calculating a date
You can add or subtract a specified amount of time to, or from, a date to calculate a new date. For example, the following information is stored for each order record: the date on which the order was placed and the shipment time in days. You want to calculate the date that customers can expect to receive their orders. Given those two fields, calculate the new date by adding the number of shipping days to the date on which the order was placed. Use BIRT’s BirtDateTime.addDay( ) function to calculate the new date. The addDay( ) function takes two arguments: the starting date and the number of days to add.
The following expression shows how to calculate the expected delivery date:
BirtDateTime.addDay(row["orderDate"], row["shipTime"])
You can also calculate a new date by adding a specified number of seconds, minutes, hours, weeks, months, quarters, or years. Use the corresponding add<time period> function. The following expression uses the addMonth( ) function to add two months to each value in the startDate field and return the date:
BirtDateTime.addMonth(row["startDate"], 2)
To subtract a specified amount of time, specify a negative number for the second argument, as shown in the following example:
BirtDateTime.addMonth(row["startDate"], -2)