Home
Analytics
Listing all dates between two dates
scottstown
Hello,
I am pretty new to using BIRT and I am stuck good this time. I have two input dates which I know how to use. But I am trying to make a list of all the dates in between these two and this is the part I don't know how to do.
So I enter: From 1/1/11 and To 1/5/11 and I want to get
1/1/11
1/2/11
1/3/11
1/4/11
1/5/11
How would I do this? When I figure this out I want to use a table group to list the all in order.
Thank you!
Find more posts tagged with
Comments
scottstown
Anyone have suggestions for how to do this?
Thanks again,
Scott
rihanna
Maybe you can create computed column using this function: BirtDateTime.addDay()
rihanna
Here is the description of the function: addDay(date:DateTime, n:Number) : DateTime
scottstown
Thanks Rihanna.<br />
<br />
That does give me a list of days, however how would I make it stop counting?<br />
<br />
Thanks again!<br />
<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'rihanna'" data-cid="79820" data-time="1310138197" data-date="08 July 2011 - 08:16 AM"><p>
Here is the description of the function: addDay(date:DateTime, n:Number) : DateTime<br /></p></blockquote>
rihanna
You are welcome!
Stop if it's equal to the second date or 1/5/11 in your example.
scottstown
Thanks again!<br />
<br />
I am having trouble writing it now.. this is what I have so far..<br />
<br />
I am doing this as a computed column using variables to store data. <br />
<br />
if (vars["counter"] == '1')<br />
{<br />
if (params["rp_FromDate"].value != params["rp_ToDate"].value) <br />
(BirtDateTime.addDay(params["rp_FromDate"].value,1))<br />
params["rp_FromDate"].value = vars["date"]<br />
(vars["counter"],1)<br />
}<br />
else {<br />
if (vars["date"] != params["rp_ToDate"].value) <br />
(BirtDateTime.addDay(params["rp_FromDate"].value,1))<br />
vars["date"] = vars["date"]<br />
(vars["counter"],1)<br />
}<br />
<br />
But I can't get it working. Any help? I don't understand the birt syntax very well yet. <br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'rihanna'" data-cid="79826" data-time="1310141284" data-date="08 July 2011 - 09:08 AM"><p>
You are welcome! <br />
<br />
Stop if it's equal to the second date or 1/5/11 in your example.<br /></p></blockquote>
rihanna
I'm also new to BIRT. Seems like you may have to create a Scripted DataSource where you can have a loop until the date column is equal to rp_ToDate, but I don't know much about Scripted DataSources to help you.
Maybe this sample will be helpful:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/544-sample-birt-scripted-data-source-example/
Hans_vd
If you happen to have an Oracle database as a datasource, you could write a query like this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
WITH params AS (
SELECT ? date_from,
? date_to
FROM dual
)
SELECT date_from + (ROWNUM - 1)
FROM params
CONNECT BY date_from + (ROWNUM - 1) <= date_to
</pre>
<br />
Regards<br />
Hans