Date Conversion

I am trying to create "Date" custom field in Jasper studio.

How do i caluclate date difference in sql query in jasper?

I tried this way, but its not working

For example datediff(dd,open_date,getdate())..

Open date is stored in timestamp format.

Please help me.


swapna_gelle's picture
Joined: Jun 12 2017 - 5:58am
Last seen: 5 years 7 months ago

You can use CAST ( your_date as DATE) to convert your_date to DATE format. Then, in a field, you can write :

$F{closed_date} - $F{open_date}. It will display the day difference between. Hope it works well, cheers ^^

dohungnd94 - 5 years 11 months ago

1 Answer:

SQL syntax depends on the database you are using. If you are using MySQL, the command to get the difference between dates is datediff.

Use FROM_UNIXTIME function to convert from timestamp to date.


hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 11 months ago