BIRT Date Functions Format Help

Hello can someone help me format a date in my very first report? I used this: BirtDateTime.today() and it gives me “Nov. 19, 2020 12:00 AM”. This is exactly what I want except I don’t want the “12:00 AM”. I don’t know JavaScript. Can you help? And I will also need a different date field where = today’s date + 1 month ( and just show the month/year i.e. December 2020)

Thank you,

Mona

@MJRIOUX

There is no need to use JavaScript.
You may get the requested result using such an expression in your report

"Date: " + Formatter.format(BirtDateTime.today(), “yyyy-MM-dd”)

The output is

Date: 2020-11-21

To create the second field you may either calculate that in your workflow. Or using a BIRT function like

BirtDateTime.addMonth()

in the report might also work.

1 Like

Thanks @knimediger! I got today’s date to work without the time but I’m still confused about how to add one month to today’s date and only show i.e. Dec 2020. I have tried this and many other versions but I can’t seem to get it to work.

"Lifting Location Schedule for " + Formatter.format(BirtDateTime.addMonth(), “MMM-yyyy”)

I appreciate your help, I’m new to this.

Mona

BirtDateTime.addMonth() is a function and requires some parameters.
May I draw your attention to the documentation https://www.ibm.com/support/knowledgecenter/SS4JE2_7.5.5/org.eclipse.birt.doc/birt/ScriptingReference.24.3.html#241080 ?
You will also get some help in the expression editor of BIRT. Drilling down BIRT functions -> BirtDateTime -> the right hand table will show available functions with required parameters.
You may try this expression which might bring a solution for your requirement

Formatter.format(BirtDateTime.addMonth(BirtDateTime.today(), 1), “MMM dd yyyy”)

HTH

2 Likes

Thank you @knimediger! This worked perfectly. I’ll check out the resources you referenced.

Mona

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.