Autor Beitrag
Josef-B
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Sa 27.12.03 16:36 
Ich möchte in eine IB-Datenbank aus einer anderen Anwendung Daten übernehmen.

Dabei habe ich auch mehrere Datums-Felder: Die Daten sind in der externen Anwendung als Ganzzahl wie folgt gespeichert: JJJJMMTT, also z.B. 20031227, wie gesagt als Zahl.

Wie kann ich die Zahl in ein Datum als Interbase-Datentyp umwandeln?
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Sa 27.12.03 18:22 
Wie wäre es, die Ganzahl in einen String umzuwandeln und dann zu zerlegen ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Datum:=inttostr(datumszahl);

Jahr:=copy(datum,0,4);

...


Nur so ein Gedanke ..
UWER
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 79

SUSE 8.1, XP Home
D7 Prof. , Kylix 3
BeitragVerfasst: Di 30.12.03 15:21 
Ich würde es etwas anders machen:

Ich würde mir erst mal die Jahr, Monat und Tag aus der Zahl basteln und dann mit EncodeDate mir das Datum ermitteln. Also ungefähr so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
    nYear, nMonth, nDay, nDate : integer;
    rDate : TDateTime;

begin
   nDate := 20031227;
   nDay := nDate mod 100;
   nDate := nDate div 100;

   nMonth := ndate mod 100;
   nYear := nDate div 100;

  rDate := EncodeDate(nYear, nMonth, nDay);

end;


Wobei dann rDate dein Datum im richtigen Format ist.

_________________
Gruß
UWER
Josef-B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 293

2003 Server, Win7, Win8
Delphi 2010 Pro, Firebird 2.5
BeitragVerfasst: Mi 07.01.04 13:40 
Probier ich aus, danke