其他分享
首页 > 其他分享> > WeeksInAYear、WeeksInYear、DaysInAYear、DaysInAMonth、DaysInYear、DaysInMonth - 获取指定年月的周、日数

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

作者:互联网

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

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.


DateUtils-Function
posted on 2009-05-20 17:53  万一  阅读(3772)  评论(0)  编辑  收藏

标签:DaysInAYear,DateUtils,WeeksInAYear,DaysInAMonth,指定,WeeksInYear,dt,2009
来源: https://blog.51cto.com/u_14617575/2748101