Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Datum in gültiges Datum umwandeln (https://www.delphipraxis.net/7092-datum-gueltiges-datum-umwandeln.html)

Tpercon 1. Aug 2003 13:25


Datum in gültiges Datum umwandeln
 
Ich lese aus einer txt Datei ein Datum in der Form YYYYMMDD aus. Gibt es eine fertige Funktion die das in das Format DDMMYYYY bringt? Bisher zerleg ich mir das selbst und stell es wieder zusammen.

Duffy 1. Aug 2003 13:27

Re: Datum in gültiges Datum umwandeln
 
Hallo Tpercon,
StrToDateTime und FormatDateDate
bye

Tpercon 1. Aug 2003 13:36

Re: Datum in gültiges Datum umwandeln
 
Genau bei StrtoDateTime liegt da aber das Problem, da YYYYMMDD ja kein gültiges Datumsformat ist!

Duffy 1. Aug 2003 13:43

Re: Datum in gültiges Datum umwandeln
 
Hallo Tpercon,
stimmt, hier die Alternative
Delphi-Quellcode:
function YYYYDDMM2DDMMYYY(DateTimeStr: string): string;
begin
  Result := Copy(DateTimeStr, 7, 2) +
            Copy(DateTimeStr, 5, 2) +
            Copy(DateTimeStr, 1, 4);
end;
bye

Tpercon 1. Aug 2003 13:46

Re: Datum in gültiges Datum umwandeln
 
"Diese" selbstgeschriebene Funktion benutz ich ja bisher, wollte halt wissen, ob es schon eine fertige gibt.
Trotzdem danke

Duffy 1. Aug 2003 13:49

Re: Datum in gültiges Datum umwandeln
 
Hallo
schau ma lhier nach, vieleicht findest Du was ...
ESBDates™ v3.0.1 - Collection of over 275 Date & Time Routines for Borland® Delphi™ to supplement those supplied by SysUtils. Includes TimeZone (incl RFC822 support) Calculations, Date Arithmetic, Week Number Calculations, Easter Calculations, ISO-8601 Compliant Routines etc. Includes Primoz Gabrijelcic's GpTimeZone routine collection. Designed for Delphi™ 4, 5 & 6, but should work with Delphi™ 2 & 3 and C++ Builder™ 4 & 5. Includes Help File and Full Source. Freeware.
bye

BennyM 2. Mär 2006 12:25

Re: Datum in gültiges Datum umwandeln
 
Hallo,

weis nicht ob das noch aktuell ist hatte aber heute das selben Problem.

Ich habe es wie folgt gelöst.

Delphi-Quellcode:
  var
    Datum : String;
    Datum_neu : TDateTime;
  ...
 //Erst ShortDateFormat und DateSeperator setzen
  Datum          := '2006-01-01 10:00:00';
  ShortDateFormat := 'yyyy-mm-dd';
  DateSeparator  := '-';
 
  Datum_neu := StrToDateTime(Datum);
Viele Grüße

Benny


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:20 Uhr.

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