如何判断某天是大月的29日,还是小月的28日,如果是就发出提示?
解决方案 »
- AdoQuery在多线程中执行错误的sql语句为什么不报错?
- 请教修改ADOQuery查询语句
- 刚学DELPHI,想问个问题~~~会的请进
- 运行时出错了,怎么回事啊?郁闷哦
- WIN的快捷方式属性对话框中,显示的标签内容,当鼠标移动到上方时,会变成可选择的形状,这是如何实现的。
- 急求 Dephi下载地址!!!在线等!!
- 简单问题:如何判断流对象(tmemorystream)已经被创建??
- 关于Listbox的问题??在线求急!!!
- ※※ ¥8000 ~¥12000月薪能招到什么样的程序员? ※※
- a为什么在预览报表的时候会先跳出装载报表控件的窗体,然后才能预览报表?是什么错误造成的?
- 能不能给段代码实现如何用adostroedproc调用这个存储过程的。谢谢!
- dxDbGrid如何在数据记录移动时判断其数据合法性,不合法的话 不post,回到原编辑行
function DaysInAMonth(const AYear, AMonth: Word): Word;
可能是你想要的, 得到一個月是有多少天!!
var
s1,s2:word;
begin
s1:=strtoint(edit1.text);
s2:=strtoint(edit2.text);
edit3.text:=inttostr(DaysInAMonth(s1,s2));
end;
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;
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;
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;
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;
看看这个可能对你有启示