?
Solved

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

Posted on 2009-05-15
11
Medium Priority
?
159 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:hidrau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24395347
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 !!!
0
 
LVL 1

Author Comment

by:hidrau
ID: 24395700
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;
 Adate       :tdatetime;
 V1, v2, v3 : String;
begin
  V1    := ' Hour per month, ';
  V2    := ' days = ';
  V3    := ' minutes per day ';
  no    :=0;
  adate :=EncodeDate(ayear, amonth,1);
  no_w  :=DaysInMonth(adate);
  for i:=1 to no_w do
  begin
    if (DayOfWeek(adate) >= 2) AND (DayOfWeek(adate) <= 6) then no:=no+1;
    adate:=incday(adate);
  end;
 
//  LB_ESQUEMA.Caption := inttostr(ahours) + Fmenu.PegaVariavel('FTEMPOAULA_01') + inttostr(no)+ Fmenu.PegaVariavel('FTEMPOAULA_02') + inttostr(round(ahours*60/no))+Fmenu.PegaVariavel('FTEMPOAULA_03')+ #13#10+
//             inttostr(ahours)+Fmenu.PegaVariavel('FTEMPOAULA_01')+ inttostr(no_w)+Fmenu.PegaVariavel('FTEMPOAULA_02')+inttostr(round(ahours*60/no_w))+Fmenu.PegaVariavel('FTEMPOAULA_03');
 
  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.

Open in new window

0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24395805
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24395819
for the formula
query pseudo :

total - sum (end_time - start_time) = still_to_go
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 24399412
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.
If that's not right for you then how about this one:
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.

0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 24400205
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
answer:
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
where add = '1'
  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
compare day finished to deadline to know if ahead or not
 
anything you don't understand about this simple algorithm ?

Open in new window

0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 24400246
Can you explain the add column? It is obviously a flag of some kind, but I'm not sure for what.
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 24400253
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.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24401286
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
0
 
LVL 1

Author Comment

by:hidrau
ID: 24411475
rfwoolf:

well, I am returning to this project today.

Just answering your question:

>>"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?
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 31626564
THANKS
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question