//日期3=日期2-日期1(格式:YYYY-MM-DD)
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit3.text :=inttostr(trunc(StrToDate(edit2.text) - StrToDate(edit1.text)));
end;//日期4=日期1加1(格式:YYYY-MM-DD)
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit4.text :=DateToStr(Succ(trunc(StrToDate(edit1.text))));
end;//日期5=日期1格式化(变成YYYYMMDD)
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit5.text :=FormatDateTime('yyyymmdd',StrToDate(edit1.text));
end;//日期6=日期4格式化(变成YYYYMMDD)
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit6.text :=FormatDateTime('yyyymmdd',StrToDate(edit4.text));
end;
//日期递增(格式:YYYY-MM-DD)
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit7.text :=DateToStr(Succ(trunc(StrToDate(edit7.text))));
end;//格式化递增
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit8.text :=FormatDateTime('yyyy-mm-dd',(Succ(trunc(StrToDate(edit8.text)))));
Edit9.text :=FormatDateTime('yyyymmdd',StrToDate(edit8.text));
end;
解决方案 »
- 这样设个类的类有什么好处呢?
- 请教!service application 运行大约10秒就自己退出的问题.
- 新手,要分的快!!!Random(255)?
- listview中的item能否变灰,也就是使某些项不能选
- 请问delphi 写 *.txt 文件的语句是什么?谢谢!
- 一个基本的问题,高手请进
- 怎样实现目录的拷贝?
- idhttp能否自己控制读取?实在对不起。我没分啊。哪位大哥帮一下我。我急用
- 急!急!急!远程文件传送问题:两台计算机通过modem拨号网络连接成功后,如何得到远程计算机的动态ip地址? (高分)
- 问一个小技巧问题:
- 请教如果让treeview1焦点定位在第一个子节点呢?
- DELPHI的JPEG的SAVETOFILE函数是不是有问题啊?
///////////////////////////////////////////////////////////////////////////
// 功能:获得某日期所在月份的第一天 //
// 入口参数:TDateTime 某日期 //
// 返回值: 某日期所在月份的第一天 //
///////////////////////////////////////////////////////////////////////////
function MonthBegin(Date:TDateTime):TDateTime;
var
T:String;
var
Year, Month, Day{, Hour, Min, Sec, MSec}: Word;
begin
DecodeDate(Date, Year, Month, Day);
T:=IntToStr(Year)+'-'+IntToStr(Month)+'-';
Result:=StrToDate(T+'1')
end;///////////////////////////////////////////////////////////////////////////
// 功能:获得某日期所在月份的最后一天 //
// 入口参数:TDateTime 某日期 //
// 返回值: 某日期所在月份的最后一天 //
///////////////////////////////////////////////////////////////////////////
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;///////////////////////////////////////////////////////////////////////////
// 功能:获得开始日期到结束日期的天数 //
// 入口参数:Date1,Date2 开始日期结束日期 //
// 返回值:天数 //
///////////////////////////////////////////////////////////////////////////function DateToDateOfDayS(Date1,Date2:TDateTime):Integer;
begin
Result:= (DateTimeToTimeStamp(Date1).Date-DateTimeToTimeStamp(Date2).Date);
if Result<0 then Result:=-Result;
Result:=Result+1;
end;
根据月份,判断!
Case语句就搞定了!