Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mo 09.04.07 19:58 
Hallo,

ich versuche zu berechnen wieviele Tage zwischen dd und nowdate liegt.
Bitte ohne der unit DateUtils. Befehl ist mir bekannt nur soll die File nicht groß werden.

Das Einlesen mit der Registry geht problemlos. Da fehlt ein wenig Code, ich weiß.
Das Problem liegt nur wie ich mit dd und nowdate rechne.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  dd,nowdate : TDateTime;

begin
  nowdate := date;
  dd := EncodeDate(regist.ReadInteger('YY'), regist.ReadInteger('MM'),regist.ReadInteger('DD'));
  result := Integer(DateToStr(dd - nowdate));
end;
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 09.04.07 20:05 
Hallo,

Tdatetimewerte sind double-werte, warum Datetostr? du kannst doch schon mit dd und nowdate einfach rechnen.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 09.04.07 20:06 
DaysBetween()

_________________
Markus Kinzler.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 09.04.07 20:06 
Warum nicht einfach DaysBetween (Uses DateUtils)?

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 09.04.07 20:11 
user profile iconBiarchiv hat folgendes geschrieben:

Bitte ohne der unit DateUtils.

wollte er nicht ;)

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 09.04.07 20:19 
Zitat:
Bitte ohne der unit DateUtils.
Wahre Profis machen alle selber :wink:

_________________
Markus Kinzler.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 09.04.07 20:26 
So Richtig hab Ich nicht verstanden was Du meinst aber..
ausblenden Delphi-Quelltext
1:
Caption:=IntToStr(Trunc(StrToDate(datenow) - StrToDate(dd)));					

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 10.04.07 10:07 
user profile iconKeldorn hat folgendes geschrieben:
user profile iconBiarchiv hat folgendes geschrieben:

Bitte ohne der unit DateUtils.

wollte er nicht ;)

Dann kann er die Funktion ja aus DateUtils rauskopieren ;-)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function DaysBetween(const ANow, AThen: TDateTime): TDateTime;
begin
  if ANow < AThen then
    Result := AThen - ANow
  else
    Result := ANow - AThen;

  Result := Trunc(Result);
end;

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Di 10.04.07 10:11 
user profile iconBlackheart666 hat folgendes geschrieben:
So Richtig hab Ich nicht verstanden was Du meinst aber..
ausblenden Delphi-Quelltext
1:
Caption:=IntToStr(Trunc(StrToDate(datenow) - StrToDate(dd)));					


Ums ganz perfekt zu machen:

ausblenden Delphi-Quelltext
1:
Caption:=IntToStr(Abs(Trunc(StrToDate(datenow) - StrToDate(dd))));					

_________________
Bravery calls my name in the sound of the wind in the night...
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 10.04.07 20:25 
user profile iconnoidic hat folgendes geschrieben:
user profile iconBlackheart666 hat folgendes geschrieben:
So Richtig hab Ich nicht verstanden was Du meinst aber..
ausblenden Delphi-Quelltext
1:
Caption:=IntToStr(Trunc(StrToDate(datenow) - StrToDate(dd)));					


Ums ganz perfekt zu machen:

ausblenden Delphi-Quelltext
1:
Caption:=IntToStr(Abs(Trunc(StrToDate(datenow) - StrToDate(dd))));					

Scheint ja auch nicht allzu wichtig gewesen zu sein.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mi 11.04.07 17:09 
Hallo,

danke.