[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Ireport default Value expression question

Posted on 2013-06-27
8
Medium Priority
?
2,048 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilationā€¦
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

650 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