Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Datum umwandeln.. (https://www.delphipraxis.net/156577-datum-umwandeln.html)

himitsu 7. Dez 2010 23:01

AW: Datum umwandeln..
 
Zitat:

Ungültiges Argument zum Codieren des Datums
Welchen Wert soll denn "Jahr" dort haben?
Du hast diesem noch garnichts zugewiesen ... da hannst'e froh sein, daß hier rein zufällig ein Wert drinsteht, der eine ungültige Jahreszahl darstellt.

mkinzler 8. Dez 2010 05:22

AW: Datum umwandeln..
 
Eine Konstante ist konstant. Man kann an sie nichts mehr anhängen

Metallicwar 8. Dez 2010 07:54

AW: Datum umwandeln..
 
Ich Volldepp.

hätte dem jahr schon noch nen genauen Wert zuweisen sollen.
Delphi-Quellcode:
  DecodeDate(now, jahr, monat, tag);

Metallicwar 8. Dez 2010 09:41

AW: Datum umwandeln..
 
Delphi-Quellcode:
  Anzeige := ' von ' + FormatDateTime( 'dd.mm.yyyy', von) + ' bis ' + FormatDateTime( 'dd.mm.yyyy', bis);

  Anzeige := SDatumVon + ' ' + DateToStr(von) + SDatumBis + ' ' + DateToStr(bis);
  SDatum := 'Datum von: %s' + #13#10 + '            bis: %s';

  Anzeige := Format(SDatum, [DateToStr(von), DateToStr(bis)]);
könnte mir bitte nochmal jemand erklären was hier alles geschieht, einiges ist mir noch nicht wirklich klar. Schließlich sollte man den Code vestehen, den man verwendet!!!

Aktueller Stand:
Delphi-Quellcode:
const
  SDatumVon0101 = 'Datum von 01.01.';
  SDatumBis3112 = 'Datum bis 31.12.';
  SDatumVon = 'Datum von';
  SDatumBis = ' bis';

....

procedure TfrmUmwandeln.Button1Click(Sender: TObject);
var
  jahr, monat, tag: Word;
  von, bis: TDate;
  Anzeige: String;
  SDatum: String;
  sDatumVon, SDatumBis: String;
begin
  pnlPrjConst.Visible := True;

  decodedate(now, jahr, monat, tag);
  von := EncodeDate( jahr, 1, 1);
  bis := EncodeDate ( Jahr, 12, 31);

  Anzeige := ' von ' + FormatDateTime( 'dd.mm.yyyy', von) + ' bis ' + FormatDateTime( 'dd.mm.yyyy', bis);

  Anzeige := SDatumVon + ' ' + DateToStr(von) + SDatumBis + ' ' + DateToStr(bis);
  SDatum := 'Datum von: %s' + #13#10 + '            bis: %s';

  Anzeige := Format(SDatum, [DateToStr(von), DateToStr(bis)]);

  lbPrjDatumAlt.Caption := SDatumVon0101 + IntToStr(jahr) + #13#10 + ' ' +
                           SDatumBis3112 + IntToStr(jahr);
  lbPrjDatumNeu.Caption := Anzeige;
end;

Nochmals eine Frage, ich kann meine Konstanten SDatumVon0101 uns SDatumBis3112 nicht in ein anderes Format umwandeln, da es Konstanten sind und immer einen festen Wert besitzen, der nicht veränderbar ist? Richtig verstanden?


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:30 Uhr.
Seite 2 von 2     12   

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