Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Displaying month on a report
vensw
Hey all,
I am trying to display the previous month in a report not the current one. Please help me out guys. Thanks !!
Find more posts tagged with
Comments
vensw
<blockquote class='ipsBlockquote' data-author="'evs'" data-cid="76564" data-time="1304430060" data-date="03 May 2011 - 06:41 AM"><p>
Hey all,<br />
<br />
I am trying to display the previous month in a report not the current one. Please help me out guys. Thanks !!<br /></p></blockquote>
<br />
Did not find the solution for this. But the month was hrd coded. Thanks !
mwilliams
Do you mean the previous month in comparison to today's date? For example, today, the report would run for April? If so, you could grab today's date with the new Date() function, grab the month with .getMonth(), subtract 1 from this value and then you'd have the previous month's integer value. Let me know.
Rosh 69
Hi mwilliams,
Hope you are fine.
With reference to your suggestion above, it may give the data for the last month of the previous years as well, right?
In my case, I only want the data of the last month of the existing year. ( Or previous year when the report is generated in January)
Any leads in this would be of great help.
Thanks,
Roshan.
mwilliams
If you do something like: lastMonth = BirtDateTime.month(BirtDateTime.addMonth(new Date(),-1)); you can grab last month no matter what month it currently is. If you want to test this, drop this into a dynamic text in a report and run it:
lastMonth = BirtDateTime.month(BirtDateTime.addMonth(new Date(),-5));
It'll give you 12 for December.
Hope this helps.
Rosh 69
Hi mwilliams, <br />
Thanks for your response and sorry for the delay in replying.<br />
<br />
In our case, the report is scheduled on the 1st of every month. <br />
<br />
So, to obtain the first and last date of the previous month, this is what I did : <br />
<br />
<strong class='bbc'><span class='bbc_underline'>First Day of previous month :</span></strong><br />
<br />
<span style='color: #8B0000'>BirtDateTime.addSecond(BirtDateTime.addDay(BirtDateTime.addSecond(BirtDateTime.today(), -1), -BirtDateTime.day(BirtDateTime.addSecond(BirtDateTime.today(), -1))), -86399)</span><br />
<br />
<strong class='bbc'><span class='bbc_underline'>Last Day of previous month :</span></strong><br />
<br />
<span style='color: #8B0000'>BirtDateTime.addSecond(BirtDateTime.today(), -1)</span><br />
<br />
<br />
And then I use the concerned date field to be between the First Day and Last Day.<br />
<br />
It seems to work fine.<br />
<br />
Regards,<br />
Roshan.
mwilliams
Great. Glad to see it's working for you. Let us know whenever you have questions!
appform
<p>Hi,</p><p> </p><p>I am writing below code in beforeOpen method to check with current month.But i am getting error.</p><p> </p><p> if(BirtDateTime.getMonth() == 1){
this.queryText = this.queryText + " "+ " AND MONTH(n.created_date)= 12 AND YEAR(n.created_date) = YEAR(CURDATE())-1 ";
}</p><p> </p><p>Please advise me how to use birt date functions in beforeOpen method.</p><p> </p><p>Regards,</p><p>Swapna.</p><p> </p><p>
</p>