Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How many days are the items rented...

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
I have a work-made rental system, and i am trying to get it to figure out how to do the following...

The database looks like so...

CLIENT CODE IN DATE OUT DATE INCOME
David 6321 10/ 4/05 18/ 4/05 $150.00
Jason 6321 20/ 4/05 26/ 4/05 $ 60.00
Jason 6152 8/ 4/05 30/ 4/05 $205.50

What i want is my boss to click to select to dates from date pickers... "StatStart" and "StatFinish" and then click a button and the following data is shown (in either a StringGrid or DataGrid or some such thing)...
CODE
DAYS OF USE
NO. OF CLIENTS
INCOME DURING PERIOD
INCOME PER DAY

Any ideas how?

Delphi, Delphi, Delphi. Oi! Oi! Oi!
 
The best solution will probably depend on the SQL capabilities of your DBMS. Which DBMS are you using? It would also help if you could show the actual required output for your three row sample data.

Assuming that the output consists of one row per code number you could create a (temporary) table of distinct codes and then do the necessary processing for each code.

I suggest you proceed along these lines and if you get stuck post the code where you are having a problem.

Andrew
Hampshire, UK
 
I'm using Delphi 7 and Microsoft Access.

CODE (Example: 6321)
-- Is the objects code number
DAYS OF USE (Example: 14)
-- The number of days during the 2 selected dates when the object was hired
NO. OF CLIENTS (Example: 2)
-- The amount of clients which hired out the object during the period
INCOME DURING PERIOD (Example: $158.57)
-- The amount of income generated by the object during the period, if in the above example the dates where 8/4/05 and 20/4/05 (so 14 days inclusive). The object 6321 would generate all the income from David's hire ($150) and 1 days worth of Jason's hire (one seventh of $60).
INCOME PER DAY (Example: $11.33 per day)
-- The amount in the previous column, divided by the amount of days selected.

Delphi, Delphi, Delphi. Oi! Oi! Oi!
 
in the above example the dates where 8/4/05 and 20/4/05 (so 14 days inclusive)
How do you get 14 days here?

It would help if you could show the actual required output for your three row sample data. Please use your boss's selected dates of 12/4/05 to 22/4/05 as this would eliminate some ambiguities.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top