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}'
Alain BensimonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

NorieAnalyst Assistant Commented:
Have you tried the juliandate function?

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

What data type are the fields rental_end_date and rental_start_date?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Pawan KumarDatabase ExpertCommented:
Please try this -

julianday

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
NorieAnalyst Assistant Commented:
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
SQL

From novice to tech pro — start learning today.