Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi FormatDateTime funktioniert auf einmal nicht mehr (https://www.delphipraxis.net/102104-formatdatetime-funktioniert-auf-einmal-nicht-mehr.html)

toyoman 23. Okt 2007 14:57


FormatDateTime funktioniert auf einmal nicht mehr
 
Delphi-Quellcode:
var
  stunden,minuten: integer;
  durchschnittprotag,totalminuten: integer;
  i:integer;
  s:string;
Delphi-Quellcode:
          durchschnittprotag:=totalminuten div cdRechnen.fieldbyname('ANTEIL_TAG').AsInteger;
          s:=formatdatetime('hh:nn',durchschnittprotag div 24);
          if i=1 then ed_schnitt_1.text:=s:
DurchschnittproTag ergibt in Minuten 504.
Wenn ich den FormatDateiTime anwenden wie im Beispiel oben bekomme ich komischerweise immer : 00:00. Warum das? Ich verstehs nicht. In einer anderen Prozedur verwende ich den praktisch gleichen Befehl und funktioniert...

seht ihr einen Fehler?

Klaus01 23. Okt 2007 15:11

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
vielleicht so?
Delphi-Quellcode:
s:=formatdatetime('hh:nn',durchschnittprotag /24);
Grüße
Klaus

Hawkeye219 23. Okt 2007 15:18

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
Hallo,
Zitat:

Zitat von Klaus01
vielleicht so?

504 ist ein Vielfaches von 24...

Delphi-Quellcode:
FormatDateTime('hh:nn', durchschnittprotag * 60 / 86400);
Gruß Hawkeye

toyoman 23. Okt 2007 15:21

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
Funktioniert tatsächlich so, aber wie kommst du auf 86400?
Ich kann dir nicht folgen...

Zitat:

Zitat von Hawkeye219
Hallo,
Zitat:

Zitat von Klaus01
vielleicht so?

504 ist ein Vielfaches von 24...

Delphi-Quellcode:
FormatDateTime('hh:nn', durchschnittprotag * 60 / 86400);
Gruß Hawkeye


Blackheart 23. Okt 2007 15:29

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
Wieviel sec. hat denn der Tag. :wink:

shmia 23. Okt 2007 15:36

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
FormatDateTime('hh:nn', xxx) kann maximal 23:59 liefern, da der ganzzahlige Anteil (entspricht den Tagen) intern abgetrennt wird.
Also kann man folgendes schreiben:
Delphi-Quellcode:
s:= Format('%d Tage', [Int(x)])+formatdatetime('hh:nn', Frac(x));

Hawkeye219 23. Okt 2007 15:45

Re: FormatDateTime funktioniert auf einmal nicht mehr
 
Hallo shmia,

nimm Trunc statt Int, dann paßt es:

Delphi-Quellcode:
s:= Format('%d Tage ', [Trunc(x)])+formatdatetime('hh:nn', Frac(x));
Gruß Hawkeye


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:53 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz