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-e r.rental_s tart_date as decimal)+1) rental_days,
(cast(er.rental_end_date-e r.rental_s tart_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}'
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-e
(cast(er.rental_end_date-e
from c_equipment_rental er, product p
where er.product_id = p.product_id and er.request_id = '{0}'
ASKER
Yes, I did not work.
How did it not work?
What data type are the fields rental_end_date and rental_start_date?
What data type are the fields rental_end_date and rental_start_date?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops, didn't notice my typo - of course it should be julianday not juliandate.
ASKER
julianday worked well.
Thank everyone
Thank everyone
Welcome. Glad to help as always.
juliandate(er.rental_end_d