程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> WeeksInAYear、WeeksInYear、DaysInAYear、DaysInAMonth、DaysInYear、DaysInMonth - 獲取指定年月的周、日數

WeeksInAYear、WeeksInYear、DaysInAYear、DaysInAMonth、DaysInYear、DaysInMonth - 獲取指定年月的周、日數

編輯:Delphi

DateUtils.DaysInYear();
DateUtils.DaysInMonth();
DateUtils.DaysInAYear();
DateUtils.DaysInAMonth();
DateUtils.WeeksInYear();
DateUtils.WeeksInAYear();

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: TDateTime;
 w: Word;
begin
 dt := StrToDateTime('2009-5-20 11:22:33');

 {指定日期所在年的總天數}
 w := DaysInYear(dt);    //365

 {指定日期所在月的總天數}
 w := DaysInMonth(dt);    //31

 {指定年的總天數}
 w := DaysInAYear(2009);   //365

 {指定年、指定月的總天數}
 w := DaysInAMonth(2009, 5); //31

 {指定日期所在年的總周數}
 w := WeeksInYear(dt);    //53

 {指定年的總周數}
 w := WeeksInAYear(2009);  //53
end;

end.


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved