Home
Analytics
Help with getFullYear()
Jodin
I want to use the Javascript function getFullYear(), but it is not working. When I use the Javascript function, getYear(), this works. The format of the date I am using is MMyyyy. I use getMonth() to get the first two digits for the month. I am writing this script in the beforeOpen event for my dataset. Here is the code:
this.queryText = this.queryText + '\n';
// 04/08/2011 Jodin - You must add one to the month because Javascript months are zero based.
this.queryText = this.queryText + ' AND evefmm = ' + params["PeriodEndDate"].getMonth() + 1;
this.queryText = this.queryText + '\n';
this.queryText = this.queryText + ' AND evefyr = ' + params["PeriodEndDate"].getFullYear();
test_string = this.queryText;
Any ideas why getYear() works but getFullYear() does not work for me?
Find more posts tagged with
Comments
mwilliams
What is your BIRT version?
Jodin
Hey Michael, thanks for replying. I got it figured out I think. It was a formatting issue. Once I pass the date value to the getFullYear() function correctly, it works.
pricher
Hi,<br />
<br />
A good workaround is to use the <em class='bbc'>year </em>and <em class='bbc'>month </em>functions in the BirtDateTime library.<br />
<br />
To get the 4-digit year: BirtDateTime.year(params["PeriodEndDate"].value)<br />
To get the month: BirtDateTime.month(params["PeriodEndDate"].value)<br />
<br />
Notice that the <em class='bbc'>month </em>function is one-based, not zero-based as in Javascript.<br />
<br />
Hope this helps,<br />
<br />
P.
mwilliams
Ah, glad it's working for you now. I know at one point, there was an issue with using getFullYear or getYear, I can't rememeber. That's why I asked about your version.