Autor Beitrag
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 19:28 
hi ich hab in problem, wie kann ich z.B. die Tage zwischen 2 Daten ermitteln?

Es soll ungefähr so aussehen (beispiel):

vom 2.7.2002 bis 10.7.2002 sind es 8 Tage (0 Jahre, 0 Monate, 1 Woche und 1 Tag)

ich habe kein plan wie ich das machen könnte. für ein bischen code wäre ich dankbar

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Spike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 69
Erhaltene Danke: 1



BeitragVerfasst: So 04.08.02 19:36 
Schau mal in der Hilfe unter DaysBetween nach. Die Funktion macht genau was Du suchst.

mfG
Spike
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 19:39 
ui an die hilfe hab ich gar nich gedacht.. hab zu lange ausgesetzt loool danke trotzdem ich probiers mal gg

wie kann ich das heutige datum rausbekommen?

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Spike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 69
Erhaltene Danke: 1



BeitragVerfasst: So 04.08.02 19:43 
Chatfix hat folgendes geschrieben:

wie kann ich das heutige datum rausbekommen?


mit der Funktion NOW
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 20:04 
also es geht leider nicht wenn ich

label1.caption:=inttostr(daysbetween(09/07/2002,04/08/2002));

mache kommt 0 als ergebnis raus

und bei

label1.caption:=inttostr(daysbetween(09/07/2002,now));

37472

hab ich was falsch gemacht?

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Spike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 69
Erhaltene Danke: 1



BeitragVerfasst: So 04.08.02 20:15 
TDateTime ist vom Type Double. Du mußt das Datum erst umwandeln. z.B.:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
var D1,D2 : TDate;
begin
  D1 := StrToDate('9.7.2002');
  D2 := StrToDate('4.8.2002');
  Label1.Caption:=IntToStr(DaysBetween(D1, D2));
end;


Spike
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 20:20 
und wie funzt das mit "now" hab schon Date(now) probiert will aber nich *fg*

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 20:21 
habs jetzt

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
var D1,D2 : TDate;
begin
  D1 := StrToDate('9.7.2002');
  D2 := TDate(now);
  Label1.Caption:=IntToStr(DaysBetween(D1, D2));
end;


jetzt funzt es!!

thx nochmal

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 20:31 
habe trotzdem mal noch eine frage, kann ich das auch noch in monate jahre und wochen umrechnen lassen

z.b. halt 8 Tage (0 Jahre, 0 Monate, 1 Woche, 1 Tag)

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Spike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 69
Erhaltene Danke: 1



BeitragVerfasst: So 04.08.02 20:46 
wie DaysBetween gibt es auch YearsBetween, MonthsBetween und WeeksBetween.

Spike


Zuletzt bearbeitet von Spike am So 04.08.02 23:30, insgesamt 1-mal bearbeitet
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: So 04.08.02 20:54 
ja aber wie bekomme ich dann den rest also 0-6 Tage raus?

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Frankle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 04.08.02 21:17 
Titel: answer
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TimeDiffStr(dt1, dt2: TDateTime): string; 
var h, m, s, s100: Word; 
begin 
  dt1 := dt2 - dt1; 
  DecodeTime(dt1, h, m, s, s100); 
  Result := IntToStr(Trunc(dt1)) + ' Tage  ' + 
            IntToStr(h) + ' Stunden  ' + 
            IntToStr(m) + ' Minuten  '; 
end;

_________________
---------------------------
God Safe QUEEN
"The Show Must Go On"