如何判断某天是大月的29日,还是小月的28日,如果是就发出提示?分不够再加

ggdw 2003-11-04 03:11:47
如何判断某天是大月的29日,还是小月的28日,如果是就发出提示?
...全文
119 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenjianyao 2003-11-05
  • 打赏
  • 举报
回复
function MonthEnd(Date:TDateTime):TDateTime;
var
Year, Month, Day{, Hour, Min, Sec, MSec}: Word;
T:String;
begin
Result:=0;
DecodeDate(Date, Year, Month, Day);
T:=IntToStr(Year)+'-'+IntToStr(Month)+'-';
case Month of
1,3,5,7,8,10,12:Result:=StrToDate(T+'31');
4,6,9,11 :Result:=StrToDate(T+'30');
2 :if (Year mod 4 =0) and ( Year mod 100 <> 0 )
or (Year mod 400 =0 )
then
Result:=StrToDate(T+'29')
else
Result:=StrToDate(T+'28');
end;
end;
看看这个可能对你有启示
hahahahaanni 2003-11-04
  • 打赏
  • 举报
回复
daysinamonth()
Dphiwarrior 2003-11-04
  • 打赏
  • 举报
回复
function DaysInMonth(MYdate:TDate):Integer;
var
MyMonth,MyYear,MyDay : Word;
MyDayTable : TDayTable;
tmpBool : Boolean;
begin
DecodeDate(MYdate, MyYear, MyMonth, MyDay);
tmpBool := IsLeapYear(MyYear);
MyDayTable := MonthDays[tmpBool];
Result := MyDayTable[MyMonth];
end;
xiaoxiao197821 2003-11-04
  • 打赏
  • 举报
回复
哎,网速好慢。
上面三行去掉
xiaoxiao197821 2003-11-04
  • 打赏
  • 举报
回复
var
n : Word;
d : TDateTime;
var
n : Word;
d : TDateTime;
begin
d := StrToDate('2003-02-28');
n := DaysInAMonth(Yearof(d), Monthof(d));
case n of
28 : showmessage('平年二月');
29 : showmessage('闰年二月');
30 : showmessage('小月');
31 : showmessage('大月');
end
end;
boytomato 2003-11-04
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,dateutils, StdCtrls ,dateutils//这加;

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
s:string;

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text:=inttostr(daysinamonth(1999,4))
end;

楼上的方法是判断指定年,月,该月的天数.

end;
cxreal 2003-11-04
  • 打赏
  • 举报
回复
函数得到每个月包含多少天

uses DateUtils;

procedure TForm1.Button1Click(Sender: TObject);
var
s1,s2:word;
begin
s1:=strtoint(edit1.text);
s2:=strtoint(edit2.text);
edit3.text:=inttostr(DaysInAMonth(s1,s2));
end;
ggdw 2003-11-04
  • 打赏
  • 举报
回复
举个例子,我还没有用过这个函数
aiirii 2003-11-04
  • 打赏
  • 举报
回复
uses DateUtils;
function DaysInAMonth(const AYear, AMonth: Word): Word;
可能是你想要的, 得到一個月是有多少天!!

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧