Home
Analytics
Date parameters: Oracle SQL
jimseconde
<p>Hi,</p>
<p> </p>
<p>As part of my dataset, I have the following conditions in the SQL:</p>
<p> </p>
<div>...and</div>
<div>trunc(creation_date) >= to_date('01/12/2013', 'dd/mm/yyyy') and</div>
<div>trunc(creation_date) <= to_date('31/12/2014', 'dd/mm/yyyy')...</div>
<div> </div>
<div>These dates need to become parameters, but I can't get BIRT to send the right format. Presuming that the SQL looks like this for the two parameters (they're a start and end date)...</div>
<div> </div>
<div>
<div>...and</div>
<div>trunc(creation_date) >= to_date(?, 'dd/mm/yyyy') and</div>
<div>trunc(creation_date) <= to_date(?, 'dd/mm/yyyy')...</div>
<div> </div>
<div>I would expect the SQL wants a string passed to it rather than a dateTime object.</div>
<div>There's logic for both dates: </div>
<div>Start date is currently:</div>
<div>BirtDateTime.addMonth(BirtDateTime.firstDayOfMonth(BirtDateTime.today()),-12)</div>
<div> </div>
<div>End date is currently:</div>
<div>BirtDateTime.addDay(BirtDateTime.firstDayOfMonth(BirtDateTime.today()),-1)</div>
<div> </div>
<div>Is the best course to convert this to a string in dd/mm/yyyy format with quotation marks added?</div>
<div> </div>
<div>Thanks in advance.</div>
</div>
<p> </p>
Find more posts tagged with
Comments
mwilliams
Since to_date() is probably for converting a string to a date, I'd assume it'd need to accept a string. If you don't use this function in your sql, are you able to pass the date parameter to your condition? Let me know.
Hans_vd
<p>mwilliams is right.</p>
<p> </p>
<p>Sending the parameters as dates (as you already do) and changing the sql to </p>
<p> </p>
<div style="margin:0px;color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">trunc(creation_date) >= trunc(?) and</div>
<div style="margin:0px;color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">trunc(creation_date) <= trunc(?)...</div>
<div style="margin:0px;color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"> </div>
<div style="margin:0px;color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">is the way to go</div>