Dateof, timeof, Yearof, Monthof, Weekof, dayof, Hourof, minuteof, Secondof, millisecondof functions for extracting time components
Their parameters are all a tdatetime,
Dateof and timeof respectively extract the date and time, and return the tdatetime type;
Yearof, Monthof, Weekof, dayof, Hourof, minuteof, Secondof, Millisecondof, are all Word types returned.
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = Class (Tform)
Procedure Formcreate (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses dateutils;
Procedure Tform1.formcreate (Sender:tobject);
Var
Dt,d,t:tdatetime;
Year,month,week,day,hour,minute,second,millisecond:word;
Begin
DT: = Strtodatetime (' 2009-5-20 11:22:33 ');
D: = dateof (DT);
ShowMessage (Datetostr (d)); 2009-5-20
T: = timeof (DT);
ShowMessage (TIMETOSTR (t)); 11:22:33
Year: = yearof (DT);
Month: = Monthof (DT);
Week: = weekof (DT);
Day: = dayof (DT);
Hour: = hourof (DT);
Minute: = minuteof (DT);
Second: = secondof (DT);
Millisecond: = millisecondof (DT);
SHOWMESSAGEFMT ('%d,%d,%d,%d,%d,%d,%d,%d ', [Year,month,week,day,hour,minute,
Second,millisecond]); {2009,5,20,11,22,33,0}
End
End.