Link to home
Start Free TrialLog in
Avatar of Alain Bensimon
Alain Bensimon

asked on

Calculate the amount of days between two dates in sqlite

Hello,
I have a query who works fine in oracle sql and give me the amount of days between 'er.rental_end_date' and 'er.rental_start_date'.
I need it to work on sqlite, but there I always get a '0', plus the '1' that I add in the query, then I always get one.
Can someone help please.
Thank you.

select er.*,p.user_def_num1 power_consumption,
(cast(er.rental_end_date-er.rental_start_date as decimal)+1) rental_days,
(cast(er.rental_end_date-er.rental_start_date as decimal)+1) * 24 * p.user_def_num1 total_power
from c_equipment_rental er, product p
where er.product_id = p.product_id and er.request_id = '{0}'
Avatar of Norie
Norie

Have you tried the juliandate function?

juliandate(er.rental_end_date) - juliandate(er.rental_start_date)
Avatar of Alain Bensimon

ASKER

Yes, I did not work.
How did it not work?

What data type are the fields rental_end_date and rental_start_date?
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, didn't notice my typo - of course it should be julianday not juliandate.
julianday worked well.
Thank everyone
Welcome. Glad to help as always.