Sending parameters to report from Java code - jasper-reports

I need to send a timestamp value as parameter from java to JR report. I tried the following code but I'm getting a blank report.
My JRXML File:
`
`
The report works fine with normal date parameter but fails to display with Time-stamp value.
My Java code :
`
I tried various values of timestamp Ex: (new java.sql.Timestamp(2013-02-27) but it is not working.

Use:
new SimpleDateFormat("yyyy-MM-dd").parse("2012-01-01");
Simply putting:
new Date(2012-01-01);
would give definitely wrong date, probably EPOCH start date.
Ensure it's MM not mm when parsing your date for month. See SimpleDateFormat javadoc
EDIT
See the image. The date your default values will generate is around 1970.
Hence your Between Condition will get all the values between 1970 to Today.
EDIT : 2
In my opinion You are setting wrong parameter in Table's datasource.
Instead of setting From_Date & To_Date from Fields set them as parameter from the main report itself.
Refer Image.

Related

Rundeck time format

In the "Activity for jobs' page in Rundeck the execution time has a relative time field (example: "Today at 10:15 AM" or "Last Sunday at 4:51 AM") after the timestamp.
It is easy to change the date format of the timestamp by adding jobslist...format[.ko] in the i18n/messages.properties file.
It seems impossible however to change the format of the relative time message. It seems to be hard-coded in en_US with AM/PM which doesn't look too good in in non-English-speaking countries. The format is always the same regardless of the ?lang=xx parameter or the default language in the browser. Interestingly, other objects (like hovering over the field with the mouse and the duration get translated).
Has anyone successfully changed this?
Example. See the duration field
I have been trying this with the docker images (4.8.0, 4.9.0 and SNAPSHOT)
I've looked at the source code and apparently this lies somewhere in the moment.js code.
In some parts, the date formats are hard coded as you say, please add your use case on this thread.

SSRS Report Date Parameter Default for the current Year

I have an SSRS Report I've created with a "Date/Time" Parameter I have created. I am trying to create a Parameter that Defaults to the Current Year. For example in "2020" I want the Paramater to default to "01/01/2020" when we hit 2021 I want it to default to "01/01/2021" Here is what I have tried. For my default value in the parameter I have the following expression with no success.
=CDate(Year(Now())+"-"+Month(01)+"-"+Day(01))
You can do this using the following expression.
=DateSerial(YEAR(Today()), 1, 1)
You can use CDate but that relies on strings. DateSerial is easier to work with in your scenario.

Changing the default date format in classic asp when using the "date" function

I'm migrating a whole bunch of web pages that were written in classic asp over to a new server, and have discovered many references to the simple date() function, like:
if cint(left(date,instr(date,"/")-1)) < 9 then blah blah
I'm getting errors because the new server's default date format is returning yyyy-mm-dd, and the code above is expecting it to be in dd/mm/yyyy format.
Rather than manually fixing every occurrence, of which there could be hundreds, I'm looking to see if I can change the default date format for asp so that date() returns dd/mm/yyyy. I thought by simply changing the system's short date format would do the trick, but even after restarting the server it's still showing yyyy-mm-dd.
Is there a setting somewhere where you can specify the default date format when using the date() function?
This worked for me:
change global.asa, in the Sub Session_OnStart, add a line
Session.LCID=1033

Convertion parameter numeric month to title month

I have month parameter in JasperReports report which will be changed into title of month. I didn't use any query to change them. I try this code:
$P{MONTH}.intValue()==1?"JAN":
$P{MONTH}.intValue()==2?"FEB":
$P{MONTH}.intValue()==3?"MAR":
$P{MONTH}.intValue()==4?"APR":
$P{MONTH}.intValue()==5?"MAY":
$P{MONTH}.intValue()==6?"JUN":
$P{MONTH}.intValue()==7?"JUL":
$P{MONTH}.intValue()==8?"AUG":
$P{MONTH}.intValue()==9?"SEP":
$P{MONTH}.intValue()==10?"OCT":
$P{MONTH}.intValue()==11?"NOV":"DEC";
but it didn't work. Could anyone know the solution for me?
This is what I use
$F{MONTH}.intValue()==1?"JAN":
$F{MONTH}.intValue()==2?"FEB":
$F{MONTH}.intValue()==3?"MAR":
$F{MONTH}.intValue()==4?"APR":
$F{MONTH}.intValue()==5?"MAY":
$F{MONTH}.intValue()==6?"JUN":
$F{MONTH}.intValue()==7?"JUL":
$F{MONTH}.intValue()==8?"AUG":
$F{MONTH}.intValue()==9?"SEP":
$F{MONTH}.intValue()==10?"OCT":
$F{MONTH}.intValue()==11?"NOV":"DEC"
It may be the semi-colon at the end that's the problem
It may also be that you are using a Parameter - .intValue() doesn't seem valid for a Parameter

DateAdd() returns faulty Date in SQL Server Reporting Services

I have a report that takes a date as a parameter.
If I use =Parameters!Date.Value, the report runs fine.
However, if I use =DateAdd("d", 1, Parameters!Date.Value), the report is left blank, even though the formats are exactly the same:. (Note: it simply cannot run. It's not that there are no values to return as the field names don't return either.)
I have also tried =DateAdd(DateInterval.Date, 1, Parameters!Date.Value)
=DateAdd("d", 1, Parameters!Date.Value)
=DateValue(FormatDateTime(DateAdd("d", 1, Parameters!Date.Value), DateFormat.ShortDate )) and many variations thereof but I can't seem to crack it!
Update
If I use DateInterval.Month instead of DateInterval.Day then the date is still incremented as desired (12/22/2010) but the table shows up! Interesting how my local settings are dd-mm-yyyy and these dates are mm-dd-yyyy.
Try changing the locale of the report to EN-GB (I'm assuming you're in the UK), as the report might be getting confused between different date formats.