A
Anonymous
Guest
Hello everyone!
After doing several (unfortunately unsucessful ) searches on this forum I have decided to post my question here directly.
I am making a system that will automatically send time logs to (recreational) pilots and that will automatically calculate the amount they have to pay based on the total amount of hours they have flown (over a certain period of time). In order to focus on my question please consider the following database structure:
The database name is "database_time" and the table name is "table_time" (pretty self-explanatory)
I basically have two questions:
I would very much appreciate it if anyone can try to help me with this. Even though it might as well be a very easy situation for you guys, it has caused me quite a lot of headaches the past few days... :-D Thanks for your time!
Maurits
After doing several (unfortunately unsucessful ) searches on this forum I have decided to post my question here directly.
I am making a system that will automatically send time logs to (recreational) pilots and that will automatically calculate the amount they have to pay based on the total amount of hours they have flown (over a certain period of time). In order to focus on my question please consider the following database structure:
The database name is "database_time" and the table name is "table_time" (pretty self-explanatory)
Code:
mysql> SELECT * FROM database_time.table_time;
+-------------+-------------+
| flight_date | flight_time |
+-------------+-------------+
| 2004-05-05 | 01:35 |
| 2004-06-12 | 00:15 |
| 2004-06-15 | 00:35 |
| 2004-06-23 | 02:10 |
| 2004-07-01 | 00:45 |
| 2004-07-08 | 00:50 |
+-------------+-------------+
I basically have two questions:
- How can I add all flight times together to get the total amount of time flown from (for instance) 2004-06-15 (including this date) until now?
(I have searched the MySQL manual date and time functions and found a function "ADDTIME(expr,expr2)" that I thought might have something to do with this.)
- How can I multiply the value received from 1 with an hourly rate of (let's say) $ 125,-- to get the total amount that has to be payed?
My biggest problem in this situation was the fact that MySQL (or PHP for that matter) needs to convert a format like 02:30 to 2,5 in order to get an accurate calculation.
I would very much appreciate it if anyone can try to help me with this. Even though it might as well be a very easy situation for you guys, it has caused me quite a lot of headaches the past few days... :-D Thanks for your time!
Maurits