# How can I create a formula to compare my schedule time?

I would like to have 3 edits

first edit
I would inform the monthly time
example: 10 hours

Second edit
I would inform how many minutes per day I will study
example: 30 minutes

Third
the system will inform how many hours I am falling behind in my studies,
all this will be done within the current month

I am a little bit how to achieve this formula,
thanks any help
LVL 1
###### 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.

Oracle dbaCommented:
write a big note with the time you want to study that month

put a stopwatch in your pocket
when you start studying, hit start
and when you stop .... yesss ... hit stop !

some stopwatches you can even set to count down ...

you could create this simply with a program too
a countdown timer with a start/stop button.
you wouldn't have to calculate at all !!!
Author Commented:
You understood partly of my problem, maybe I haven't explained it better.

Let me give you some details.

I have a program that I developed and I use to study english.
I would like to create a study plan. Then I will inform the program how many hours per month
I will dedicate with it.

The program will advice me how many hours or minutes per day I must study to achieve my schedule.
according to passing days, my system will compute how many minutes I studied and inform me if I am falling behind or if I am up to date with my studies.

So, imagine something like this:

I've chosen 10 hours per month to study
My studied per day must be 29 minutes

I got make this so far, I developed a function to give my monthly schedule

Now I need another part, I need to get all time I have studied within my month and
compare with my schedule and inform if I am falling behind or I am up to dated.

Take a loot at my code, can you help me improve my code?

``````My dfm

object Form1: TForm1
Left = 370
Top = 121
Width = 535
Height = 215
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 32
Top = 16
Width = 78
Height = 13
Caption = 'Hours per month'
end
object Label2: TLabel
Left = 162
Top = 16
Width = 94
Height = 13
Caption = 'Hours studied so far'
end
object Edit1: TEdit
Left = 32
Top = 32
Width = 121
Height = 21
TabOrder = 0
Text = '10'
end
object Edit2: TEdit
Left = 161
Top = 31
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit2'
end
object LB_ESQUEMA: TPanel
Left = 32
Top = 88
Width = 457
Height = 89
Caption = 'LB_ESQUEMA'
TabOrder = 2
end
object Button1: TButton
Left = 312
Top = 27
Width = 75
Height = 25
Caption = 'schedule'
TabOrder = 3
OnClick = Button1Click
end
end

My pas

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DateUtils, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
LB_ESQUEMA: TPanel;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{\$R *.dfm}

procedure hour_to_learn(Ahours, AMonth, AYear:integer) ;
var
i, no_w, no :integer;
V1, v2, v3 : String;
begin
V1    := ' Hour per month, ';
V2    := ' days = ';
V3    := ' minutes per day ';
no    :=0;
for i:=1 to no_w do
begin
end;

Form1.LB_ESQUEMA.Caption := inttostr(ahours) + V1 + inttostr(no)   + V2 + inttostr(round(ahours*60/no))  + V3 + #13#10+
inttostr(ahours) + V1 + inttostr(no_w) + V2 + inttostr(round(ahours*60/no_w))+ V3;

end;

procedure TForm1.Button1Click(Sender: TObject);
Var
Hr : Integer;
begin
Hr := StrToInt(Edit1.Text);
hour_to_learn(Hr,MonthOf(Date), YearOf(Date));
end;

end.
``````
Oracle dbaCommented:
imho,
studying a language like this will not get you anywhere.
Just go to the library, select 2 or 5 books from each cabinet and read them.
You will be excellent at English after 100 books, providing the books cover a wide range of subjects.
You may need a encylcopedia for explanations ...

I studied French and English like this.
I started on Japanese, but the barrier is way bigger.
Oracle dbaCommented:
for the formula
query pseudo :

total - sum (end_time - start_time) = still_to_go
Commented:
lol @ Geert.

Yaknow, part of this type of problem-solving is what I enjoy about programming, and this isn't even that complicated. Can you not by yourself come up with a formula or algorithm and then ask us to help you put the formula into code?
Part of the problem is you haven't given us quite enough information, for example:
"the system will inform how many hours I am falling behind in my studies,
all this will be done within the current month"
So let's say today is the 15th of May. Can you give me an example of what you would put in the boxes and what the answers will be? Or does it calculate from the BEGINNING of the month? Your question is not clear on this.

Geert has given you an algorithm that could work for you.
total - (DayOfMonth(Today) * MinutesStudiedPerDay) = still_to_go
for example, if today is the 15th, it will look like this:
10 hours - (15 * 29) = 165 minutes. behind

I'm also glad to see you are using DateUtils which can come in handy for some things.

Oracle dbaCommented:
you have been reposting this question in different formats
and your gui is very complex, keep it simple, or you'll never get there.

use a db with 4 fields, index (prim key), startdate, enddate, course
you don't need anything more for this !

the algorithm works, it's the rest your messing up.

i wrote several programs for time registration on company production floors. (big companies and small companies)
it always comes down to the same thing:
calculate the delta for each record from start to finish
you may need to split the record to include breaks/toilet visits/line halts/planned halts ... whatever
then just sum it up

like this

``````id start  end    code
1  12:00  14:00  productA
2  14:00  17:00  productB
3  17:00  18:00  productC
4  18:00  20:00  productA

how long did they work on A, when
the line halted from 13:12 to 13:45
and they take breaks at 15:00 to 15:15 and 18:00 to 18:15
split according to breaks and calc deltas:
id  start  end    code     delta  add
1   12:00  14:00  productA 120    1
2   14:00  15:00  productB  60    1
2a  15:00  15:15  productB  15    0
2b  15:15  17:00  productB 105    1
3   17:00  18:00  productC  60    1
4   18:00  18:15  productA  15    0
4a  18:15  20:00  productA 105    1

now split with line halts
id  start  end    code      delta  add
1   12:00  13:12  productA  72    1
1b  13:12  13:45  productA  33    0
1c  13:45  14:00  productA  15    1
2   14:00  15:00  productB  60    1
2a  15:00  15:15  productB  15    0
2b  15:15  17:00  productB 105    1
3   17:00  18:00  productC  60    1
4   18:00  18:15  productA  15    0
4a  18:15  20:00  productA 105    1

the select:
select sum(delta) from calctimes
and code = 'productA'

result: 72 + 15 + 105 = 192
if they can work on product hour for 10 hours to complete: 600 - 192 = 408
then you can even calc the percentage they have finished: 192/600*100 = 32%
after some time you would have statistics on how much they can work on a productA, (let's say 3 hours a day)
then you can calc if they are ahead or behind for the deadline
totaltodo - currentdone = stilltogo
stilltogo / 3hoursperday = days to go
today + days to go = day finished

``````

Experts Exchange Solution brought to you by

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

Commented:
Can you explain the add column? It is obviously a flag of some kind, but I'm not sure for what.
Commented:
Silly me, with another glance I could see it's a flag on whether or not to add that record into the calculation - kind of like a "relevant?" flag.
Oracle dbaCommented:
well the add flag is really a simple method of indeed indicating if something was really done.
normally this is done by entering a code from a reasoncode table.
this reasoncodetable would allow to extend to more functionality with 1 piece of code
like for every delta you could designate:
- the type of time: break, hours worked, electric failure, machine failure, product change, etc...
- flags: billable, production hours, down hours, maintenance hours
- percentage billable
- cost center

if you chop up all time a employee worked and categorize every piece of time into this system
you get the group summary with a simple select sum group by on a daily/weekly/monthly/yearly basis
the better you can divide the time into those delta, the more accurate
like with the cost center you could determine if money is comming in or going out.
and then what you earned or what you lost
Author Commented:
rfwoolf:

well, I am returning to this project today.

>>"the system will inform how many hours I am falling behind in my studies,
>>all this will be done within the current month"

Yeah,

I have a table in access that keep the amount of minutes / hours that I have studied. This column keep the information in hh:mm

When I start my month, I inform the system what it will be the amount of hour I will dedicate on my studies. For exemplo:

My goal for this month is 15 hours.
With this information, I can split the hours in days, then I can see how many hours / minutes I need to study to achieve my goal. As you can see in the function that I have posted

With my table, I will be able to sum how many minutes / hours I have studied so far and how many minutes / hours I need to achieve my goal. If I am falling behind with the chosen schedule, the system must inform me the amount of minutes or hours I am late.

Did you get it?
Author Commented:
THANKS
###### 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
Delphi

From novice to tech pro — start learning today.