Displaying the current date
A report typically displays the date on which it is generated, so that users can tell if the data in the report is up-to-date. To display the current date, use one of the following expressions in a data element:
new Date()
BirtDateTime.now()
BirtDateTime.today()
BirtDateTime.now( ) and new Date( ) return the current date and time. BirtDateTime.today( ) returns the current date and a time value of midnight, 12:00 AM.
When the report is run, the current date appears in the format that is determined by the locale setting on the user’s system and by the data type you select when you define the data element. For example, if the locale is English (United States) and you select the Date Time data type, the date appears as follows for new Date( ) and BirtDateTime.now( ):
Jan 19, 2009 10:30 PM
For BirtDateTime.today( ), the date appears as follows:
Jan 19, 2009 12:00 AM
To display only the date portion, use any of the three functions and select the Date data type. The following value appears when you specify the Date data type:
Jan 19, 2009
To display only the time portion, use new Date( ) or BirtDateTime.now( ) and select the Time data type. The following value appears when you specify the Time data type:
10:30:45 PM
To display the date in a different format, such as 01/19/09, use the data element’s Format DateTime property to apply the desired format.