#1 2016-11-09 09:27:56

nprokofiev
Member
Registered: 2016-11-09

Trimming time issue

Hi. When I pass datetime parameter to report, time is being trimmed and mysql executes query without time. Is it a bug or misconfiguration?

Offline

#2 2016-11-17 09:06:05

kingjack
Member
Registered: 2016-11-17

Re: Trimming time issue

I think it is misconfiguration

Offline

#3 2016-11-17 09:20:04

nprokofiev
Member
Registered: 2016-11-09

Re: Trimming time issue

Thanks for reply.
What is the right way to to do it? Every time I execute
select * from TableA where dateColumn1 between ${dateFrom} and ${dateTo}
I see in mysql logs that time is trimmed.
dateFrom and dateTo parameters are in "Date and Time" mode.

Offline

#4 2017-03-03 12:02:35

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Trimming time issue

Hi nprokofiev,

we are investigating this issue. Please take a look here: https://forum.reportserver.net/viewtopic.php?id=631 and check if the workaround works for you.

Cheers,
Eduardo

Offline

#5 2017-05-16 12:07:00

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Trimming time issue

For completeness:

I took a look at this issue and it seems the standard jasper behavior, not a reportserver bug.
Reportserver passes the parameter as java.util.Date to jasper. It passes the *complete* java.util.Date to jasper, including the time component. For checking this, you can write $P!{param1} in your query (instead of $P{param1}), and check what is arriving at the database. It should be something similar to: 'Wed Mar 29 09:44:07 CEST 2017'.
Jasper seems to cut the time component when having a java.util.Date parameter in its query, take a look at http://community.jaspersoft.com/questio … -textfield for a similar issue. When having java.sql.Timestamp, this is not happening. So the "workaround" above is the correct solution.
Here the steps:
1. Create a java.util.Date parameter "param1" with isForPrompting=true
2. Create a java.sql.Timestamp parameter "param1_sql" with isForPrompting=false, and defaultValue=new java.sql.Timestamp($P{param1}.getTime())
3. Use the "param1_sql" parameter in your query, e.g.: select * from mytable where myfield < $P{param1_sql}.
The time component is not being cut anymore.

Cheers,
Eduardo

Offline

Board footer

Powered by FluxBB