Date + Rent = Payment amount
It's not date * rental fee = payment amount
right?
SELECT
(TO_DATE('2020-04-01 10:05', 'YYYY-MM-DD HH24:MI')
- - TO_DATE('2020-03-27 21:35', 'YYYY-MM-DD HH24:MI'))
* Rent + Insurance Premium
FROM MY_TABLE
You can do it this way, but the problem is calculating the date. Just looking at the example above, the date doesn't exactly match, so the value 4.5208333333333333333333
comes out. If you're not going to set the rent on an hourly basis, you have to decide whether to throw away or raise the decimal point, but this depends on the policy, so think about it.
-- Date format omitted
SELECT
-- Five days
TO_DATE('2020-04-01 10:05:00') - TO_DATE('2020-03-27 10:05:00'),
-- 4.5208333333 days
TO_DATE('2020-04-01 10:05:00') - TO_DATE('2020-03-27 21:35:00'),
-- 5.4166666666 days
TO_DATE('2020-04-01 20:00:00') - TO_DATE('2020-03-27 10:00:00')
FROM DUAL
If you set a standard time and exceed that time, the rental date is +1... There could be a policy like this.
© 2024 OneMinuteCode. All rights reserved.