一段时间2010-11-12 到2011-03-12
想得到这样的
2010年11月,2010年12月,2011年1月,2011年2月
想得到这样的
2010年11月,2010年12月,2011年1月,2011年2月
解决方案 »
- 如何fastreport4 安装到delphi7
- 好像程序员 到而立后 悲剧的居多
- 判断键盘录入的问题,彩蛋中的按键盘的记录和判断功能!
- dbedit默认只能输入4位小数,我想输入6位的?
- 用ADO连接服务器上的SYBASE时,客户端要安装什么?
- 请问 在Internet面板上找不到TClientSocked 和 TServerSocked这两个控件,怎么办?
- 各位高手赐教啊!请问在Dephi中如何可以知道Excel中的自定义宏的列表,并且调用相应的宏呢?
- 有人做过在delphi中的并口操作吗?(Delphi5.0)
- 如何從函數中將值取出來﹖﹖高手請﹗﹗﹗﹗
- 紧急求救:如何将sql查询的票据结果按所需的子段显示在另一个表单的显示控件上
- 求一段用WinSock获取html代码的程序
- 祝贺SuperTitan2XX系列问世
var
date1,date2:string;
Syear,Eyear,Smonth,Emonth:integer;
begin
date1:=formatdatetime('yyyy-mm-dd',startdate);
date2:=formatdatetime('yyyy-mm-dd',enddate);
Syear:=strtoint(copy(date1,1,4));
smonth:=strtoint(copy(date1,6,2));
Eyear:=strtoint(copy(date2,1,4));
Emonth:=strtoint(copy(date2,6,2));
if (syear-eyear)>0 then
begin
if (smonth-emonth)>0 then
result:=(syear-eyear)*12+(smonth-emonth)
else
result:=(syear-eyear)*12+(smonth-emonth);
end
else if (syear-eyear)=0 then
result:=abs(smonth-emonth)
else
begin
if (smonth-emonth)>0 then
result:=(abs(syear-eyear))*12+(-1)*(smonth-emonth)
else
result:=abs(syear-eyear)*12+abs(smonth-emonth);
end;
end;
uses
DateUtils;begin
date := StrToDate('2010-11-12');
endDate := StrToDate('2011-03-12');
while date < endDate do
begin
ShowMessage(FormatDateTime('yyyy年mm月', date));
IncMonth(date);
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
d1,d2:TDate;
begin
d1:=EncodeDate(2010,11,12);
d2:=EncodeDate(2011,3,12);
Memo1.Lines.Add(FormatDateTime('yyyy年m月',d1));
while d1 < d2 do begin
if FormatDateTime('dd',d1)='01' then begin
Memo1.Lines.Add(FormatDateTime('yyyy年m月',d1));
end;
d1:=d1+1;
end;end;end.
if FormatDateTime('dd',d1)='12' then
date0 := IncMonth(date1) 则date0为2010.12.12,与此类似,直到返回值小于date2
输出的时候,使用formatdatetime('yyyy年mm月',date0)就可以
这个好像是要返回值的
date := IncMonth(date);