怎么求某个日期的该月的月末? 比如取系统时间date或now所在月的月末日期。如2003-6-25--->2003-6-30 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼上的那个只能在oracle使用。要是在其它数据库中必须使用:1。求出当前月的下一月2。求出下一月的第一天的前一天这样才能获得答案。 完整解决方案:Form1上加三个Edit,一个Buttonprocedure TForm1.Button1Click(Sender: TObject);var Present,EndMonth: TDateTime; Year, Month, Day,EndY, EndM, EndD: Word;begin Present:=DtTmPckPDate.Date; Edit1.Text:=DateToStr(Present); DecodeDate(Present, Year, Month, Day); if Month>1 then EndMonth:=strtodate(inttostr(Year)+'-'+inttostr(Month-1)+'-'+'1') else EndMonth:=strtodate(inttostr(Year-1)+'-'+'12'+'-'+'1'); Edit2.Text:=DateToStr(EndMonth); DecodeDate(EndOfTheMonth(EndMonth),EndY, EndM, EndD); Edit3.Text:=inttostr(EndY)+'-'+inttostr(EndM)+'-'+inttostr(EndD);end; var AYear,AMonth,ADay: Word; //uses DateUtilsbegin DecodeDate(now,AYear,AMonth,ADay); EndOfAMonth(AYear,AMonth); //这就是你要的结果end; 哇噻,wongang兄好厉害。其实我就是想求上月的月末,操作数据库用,谢谢!同样谢谢各位兄弟。 抗议,我给出的是delphi的函数,郁闷!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 再发毛遂自荐视频求职帖!大家帮忙顶一顶 如何判断 时间是否是 晚上凌晨 ? 注意时间有12 /24小时制 在使用ADO连接Access时,生成SQL语句时,都有哪些特殊字符 想个简单的进销存,有人愿意教吗? 我的Blog文章:我的前沿科学(科学史上最新发现!将轰动整个学术界 ) 隐藏窗体 找人协助完成项目(郑州) 请教一个非常简单的问题 求助 用delphi控制excel的问题 delphi7 ,oracle10g有兼容性的问题吗 欢迎大家下载我的软件,下载了给分 请教获取IE版本号和office版本号的方法?
1。求出当前月的下一月
2。求出下一月的第一天的前一天
这样才能获得答案。
var
Present,EndMonth: TDateTime;
Year, Month, Day,EndY, EndM, EndD: Word;
begin
Present:=DtTmPckPDate.Date;
Edit1.Text:=DateToStr(Present);
DecodeDate(Present, Year, Month, Day);
if Month>1 then
EndMonth:=strtodate(inttostr(Year)+'-'+inttostr(Month-1)+'-'+'1')
else
EndMonth:=strtodate(inttostr(Year-1)+'-'+'12'+'-'+'1');
Edit2.Text:=DateToStr(EndMonth);
DecodeDate(EndOfTheMonth(EndMonth),EndY, EndM, EndD);
Edit3.Text:=inttostr(EndY)+'-'+inttostr(EndM)+'-'+inttostr(EndD);end;
AYear,AMonth,ADay: Word; //uses DateUtils
begin
DecodeDate(now,AYear,AMonth,ADay);
EndOfAMonth(AYear,AMonth); //这就是你要的结果
end;
同样谢谢各位兄弟。