Autor Beitrag
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 09.02.09 15:13 
Hallo,

ich habe ein eigentlich simples Problem, aber ich finde einfach nichts.
Wie gebe ich in Delphi-Quellcode ein konstantes Datum ein?
Const cDatum = #1900-12-12# funktioniert leider nicht.

Danke,
Jens

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 09.02.09 15:38 
Moin!

user profile iconNersgatt hat folgendes geschrieben Zum zitierten Posting springen:
Wie gebe ich in Delphi-Quellcode ein konstantes Datum ein?
In Delphi werden Daten bzw. Datum/Zeit-Angaben als Double gespeichert, nicht als String. :idea:

Du musst also das Datum mit einer kleinen Hilfsanwendung "umbauen":
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := 'const Heute: TDate = '+FloatToStr(Date)+';';
end;
Ausgabe:
ausblenden Quelltext
1:
const Heute: TDate = 39853;					
Das kannst du dann in deinen Quelltext einbauen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nersgatt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 09.02.09 15:52 
Danke, ich dachte, es gäbe eine Möglichkeit, das Datum human readable im Quelltext zu schreiben. Werde ich halt mit Kommentaren arbeite.

Gruß,
Jens

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
martin300
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Mo 09.02.09 16:02 
Hallo,
hier ein Codeausschnitt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  var

  MeinDatum : TDateTime;
  const einDatum = '12.12.1900';
begin
  MeinDatum := strtodate(einDatum);
  memo1.Lines.Add( datetostr(MeinDatum));


Erklärungen gibt es www.bergt.de/worksho.../html/funktion41.htm dort.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 09.02.09 16:09 
Moin!

Warum sollte ich einen String speichern, den ich nicht brauche und dann auch noch Funktionen aufrufen, die überflüssig sind? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nersgatt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 09.02.09 16:10 
user profile iconmartin300 hat folgendes geschrieben Zum zitierten Posting springen:
Hallo,
hier ein Codeausschnitt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  var

  MeinDatum : TDateTime;
  const einDatum = '12.12.1900';
begin
  MeinDatum := strtodate(einDatum);
  memo1.Lines.Add( datetostr(MeinDatum));

Funktioniert das auch auf Englischsprachigen PCs? Sorry, aber warum sollte ich eine Strinkonstante nehmen, wenn ich eine Datumskonstante will? Das ist wie links blinken und rechts abbiegen.

Zitat:
Erklärungen gibt es www.bergt.de/worksho.../html/funktion41.htm dort.

War sicherlich gut gemeint, aber wenn schon der erste Satz nicht stimmt....
Zitat:
("Delphi verwaltet das Datum als Anzahl der Tage seit dem 1. Januar 001.")


Gruß,
Jens

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)