Solved

Ireport default Value expression question

Posted on 2013-06-27
8
1,978 Views
Last Modified: 2013-07-09
Hi,

I'm new to Ireport and have been struggling to find a way to get a TODATE parameter with a class of java.sql.timestamp to default to 23:59:59.  The problem is that a Date value always defults to midnight, so if the user chooses a TODATE of today, none of the data from today would be displayed.

I know this can be corrected in the default value expression- but I can't locate the correct code to designate 23:59:59.  Can any one help?  Thanks!
0
Comment
Question by:jjg1576
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 22

Expert Comment

by:earth man2
ID: 39287237
public void testTimestamp() {
  java.util.Date date = new java.util.Date(2013,6,29,23,59,59);
  java.sql.Timestamp stamp = new java.sql.Timestamp(date.getTime());
}
0
 
LVL 35

Expert Comment

by:girionis
ID: 39290060
If you don't want to use a default value expression you can pass the parameter to a map. I'd suggest you create a date and then subtract one second from it (1000 milliseconds), so you always get the 23.59.59.
0
 

Author Comment

by:jjg1576
ID: 39290348
Thanks for your responses-

Actually, even if i knew how to use the default value expression with today's date + 1 day it would do the trick.  I'm just struggling with the code for adding 1 day.  In crystal you could use dateadd, but I don't know the equivalent in Ireport.  ANy thoughts on how to do this?

Thanks!
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 35

Expert Comment

by:girionis
ID: 39292414
How do you pass the date in your ireport template? You can create the date before-hand and pass it as a parameter in a map.

To add one day to a date you can do something like this

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 1);
Date d = cal.getTime();

Open in new window

0
 

Author Comment

by:jjg1576
ID: 39294911
Currently i am just using a third parameter.  I have FromDate, Todate and Tdate.

in the report Query I use the following code

     and testresult."testdate" >= $P{From_Date}
     and testresult."testdate" <= $P{TDate}

The TDate parameter references ToDate in it's default value expression with the following code:

$P{To_Date} + 1

Since Todate defaults to today's date (same as FromDate), the default value in TDate allows for an extra day to be added if the client enters the same day in both FromDate and Todate filters (these are the filters that prompt the user when the report is run).

So in a roundabout way this gets the data needed, it just seems like there must be an easier way to do it without making 3 parameters.
0
 
LVL 35

Expert Comment

by:girionis
ID: 39299711
Well you need three parameters since you store three dates. But you could do it with only two parameters, if you add dynamically one day to the one parameter you want.
0
 

Accepted Solution

by:
jjg1576 earned 0 total points
ID: 39300757
Ok thanks-

but really I only want two dates, just didn't seem to be a way to do it without a third.  I have it working, which is the important thing.  Just seemed odd that I could do it with two in Crystal.  Guess I still have a lot to learn about Ireport.  Thanks again for your help.
0
 

Author Closing Comment

by:jjg1576
ID: 39309798
My solution did what i wanted it to do- I just wanted to see if there was an easier way to do it.  The other solutions offered weren't specific enough.  That may be my fault as I am a novice at ireport and probably still have problems grasping some of the explanations.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question