Forum > General

Calculating hours

(1/1)

Tirans:
Hello, i cant seem to figure out how to calculate hours for a specific person. Does anyone have any ideas or tips on how should i tackle this problem?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);const  mask = 'mm/dd/yyyy"," hh:nn:ss AM/PM';  lekcijas = 7;var  Lines, list: TStringList;  s: string;  i: integer;  d, atnaca, aizgaja: TDateTime;  fs: TformatSettings; begin  Lines := TStringList.Create;  Lines.Loadfromfile('apm.csv');  list := TStringList.Create;  setLength(Fails, Lines.Count);   list.delimiter := ';';  list.strictdelimiter := True;   for i := 1 to High(Fails) do  begin    list.DelimitedText := Lines[i];    with Fails[i] do     begin      Vards := list[0];      if pos('(', Vards) > 0 then        Vards := leftstr(Vards, pos('(', Vards) - 2);      if (combobox1.items.indexof(Vards) < 0) then        combobox1.items.add(Vards);      Darbiba := not (list[1] = 'Left');       s := list[2];      fs := DefaultFormatSettings;      fs.DateSeparator := '/';      laiks := ScanDateTime(mask, s, fs);    end;  end;                 
I have managed to get the time read in the memory correctly and that works all fine, but now i need to figure out how would i calculate total hours for a person https://gyazo.com/48797ac202108236a0cd012fd1e178e1 The file that is read in looks like this and it has joined/left for every person in each day that the meeting took place. Any advice would be appriciated.

paweld:
HoursBetween function in DateUtils unit

winni:
Hi!


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var StartDate, EndDate : TDateTime;hours : single; hours := (EndDate-StartDate) / 24;  done

Winni


wp:

--- Quote from: winni on June 09, 2021, 12:53:41 pm ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var StartDate, EndDate : TDateTime;hours : single; hours := (EndDate-StartDate) / 24;done
--- End quote ---
No: times 24: hours := (EndDate-StartDate) * 24;

Navigation

[0] Message Index

Go to full version