开发者

How to convert the Date into Epoch in iReport and Jasperserver

I want to create a report for login history between two dates.

The login history table has the following fields:

login_date  (data type is integer)
user_id     (data type is integer)

Sample records

|login_date |user_id|
+-----------+-------+
|1299954600 |   105 |
|1299954600 |   105 |
|1299954600 |   105 |
|1299954600 |   105 |
|1301164200 |   114 |
|1301164200 |   106 |
|1301769000 |   110 |
|1301164200 |   106 |
|1301769000 |   106 |
|1301769000 |   106 |
|1301769000 |   106 |
|1302978600 |   102 |
|1302373800 |   112 |
|1302978600 |   111 |
|1302978600 |   111 |
|1302978601 |   111 |

Note: I have stored the login date in Epoch time.

I want to create the report for following query.

SELECT
  user_id,
  count(user_id)
FROM
  rep_time_tracking
WHERE
  login_date between 1301596200 AND 1303496940
GROUP BY 1;

I have开发者_如何转开发 added two parameters for run time parameter.

Example. ${FROM} and $P{TO}, value expression is Date/Time.

Now the user selects the date and time using the input I want to convert into Epoch.

How to achieve this in iReport and JasperServer?


Its pretty Simple, All You have to do is call a function on Date which is getTime() it gives you UTC time and then use it as Parameter in query.!

See the Screent Shot.

How to convert the Date into Epoch in iReport and Jasperserver

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜