Startofayear ... Startoftheyear ... Endofayear ... Endoftheyear ... The start and end times of each year, month, week, day
{参数是指定的年、月、周、日}
DateUtils.StartOfAYear
DateUtils.StartOfAMonth
DateUtils.StartOfAWeek
DateUtils.StartOfADay
{参数是 TDateTime}
DateUtils.StartOfTheYear
DateUtils.StartOfTheMonth
DateUtils.StartOfTheWeek
DateUtils.StartOfTheDay
{参数是指定的年、月、周、日}
DateUtils.EndOfAYear
DateUtils.EndOfAMonth
DateUtils.EndOfAWeek
DateUtils.EndOfADay
{参数是 TDateTime}
DateUtils.EndOfTheYear
DateUtils.EndOfTheMonth
DateUtils.EndOfTheWeek
DateUtils.EndOfTheDay
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm1 = Class (Tform)
Procedure Formcreate (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses dateutils;
Procedure Tform1.formcreate (Sender:tobject);
Var
Dt,t1,t2,t3,t4:tdatetime;
s1,s2,s3,s4:string;
Begin
DT: = Strtodatetime (' 2009-5-20 11:22:33 ');
T1: = Startofayear (2009);
T2: = startoftheyear (DT);
T3: = Endofayear (2009);
T4: = endoftheyear (DT);
S1: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T1); 2009-1-1 0:0:0:000
S2: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T2); 2009-1-1 0:0:0:000
S3: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T3); 2009-12-31 23:59:59:999
S4: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T4); 2009-12-31 23:59:59:999
T1: = Startofamonth (2009, 5); {May 2009}
T2: = startofthemonth (DT);
T3: = Endofamonth (2009, 5);
T4: = endofthemonth (DT);
S1: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T1); 2009-5-1 0:0:0:000
S2: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T2); 2009-5-1 0:0:0:000
S3: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T3); 2009-5-31 23:59:59:999
S4: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T4); 2009-5-31 23:59:59:999
T1: = Startofaweek (2009, 21); {2009 21st Week}
T2: = Startoftheweek (DT);
T3: = Endofaweek (2009, 21);
T4: = endoftheweek (DT);
S1: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T1); 2009-5-18 0:0:0:000
S2: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T2); 2009-5-18 0:0:0:000
S3: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T3); 2009-5-24 23:59:59:999
S4: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T4); 2009-5-24 23:59:59:999
T1: = Startofaday (2009, 140); {2009 140th Day}
T2: = startoftheday (DT);
T3: = Endofaday (2009, 140);
T4: = endoftheday (DT);
S1: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T1); 2009-5-20 0:0:0:000
S2: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T2); 2009-5-20 0:0:0:000
S3: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T3); 2009-5-20 23:59:59:999
S4: = FormatDateTime (' yyyy-m-d h:n:s:zzz ', T4); 2009-5-20 23:59:59:999
End
End.