Calculate the amount of days between two dates in sqlite

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}'
Alain BensimonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
Have you tried the juliandate function?

juliandate(er.rental_end_date) - juliandate(er.rental_start_date)
Alain BensimonAuthor Commented:
Yes, I did not work.
NorieVBA ExpertCommented:
How did it not work?

What data type are the fields rental_end_date and rental_start_date?
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Pawan KumarDatabase ExpertCommented:
Please try this -


SELECT julianday(er.rental_end_date) - julianday(er.rental_start_date) FROM YourTableName

or this

SELECT strftime('%d',er.rental_end_date) - strftime('%d',er.rental_start_date) FROM YourTableName

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NorieVBA ExpertCommented:
Oops, didn't notice my typo - of course it should be julianday not juliandate.
Alain BensimonAuthor Commented:
julianday worked well.
Thank everyone
Pawan KumarDatabase ExpertCommented:
Welcome. Glad to help as always.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.