Writing Expressions : Manipulating date-and-time data : Using specific dates in an expression
 
Using specific dates in an expression
When creating an expression that contains a specific date, you can use any of the following expressions to represent a date:
new Date(2009, 0, 31)
"2009-01-31"
"2009-01-31 15:30:30"
All the expressions represent January 31, 2009. The first expression creates a JavaScript Date object. Months in a JavaScript Date object start at 0, so January is month 0. If you cannot remember the correct date expression to type, use the calendar tool in the expression builder to select a date, as shown in Figure 11‑9. The date you select appears in the following format:
"2009-04-15 11:22:15.872-0800"
By default, the time portion of the date expression uses the current time, including the milliseconds. The -800 part of the expression indicates the time zone in the RFC 822 4-digit time zone format.
Figure 11‑9 Use the calendar tool in the expression builder to select a date
The following examples show expressions that include specific dates. The first expression returns the number of days from the current date to Christmas:
BirtDateTime.diffDay(BirtDateTime.today(), "2009-12-25")
The following expression calculates expected delivery dates. If the order date is after December 22, 2009, add the standard shipping time plus three days to the orderDate date; otherwise, add the standard shipping time.
if (row["orderDate"] >= "2009-12-20"){
BirtDateTime.addDay(row["orderDate"], row["ShipTime"] + 3)
}
else{
BirtDateTime.addDay(row["orderDate"], row["ShipTime"])
}