Delphi根据输入日期按年月周日输出日期段


本文整理自网络,侵删。

 

Delphi根据输入日期按年月周日输出日期段

输入变量ADateStart,并为其填写起始日期,变量ADateEnd,计算类型AType,

输出变量ADateStart,变量ADateEnd

procedure FormatDateByType(AType:Integer; var ADateStart, ADateEnd: TDate);

var //type 0日 1周 2月 3年

ADate :TDate;

myYear, myMonth, myDay : Word;

begin

ADate := ADateStart;

case AType of
:begin //日

ADateStart := ADate;

ADateEnd := ADate + 1;

end;
:begin //周 DayOfWeek() Sunday =1

if DayOfWeek(ADate)<>2 then // <> Monday

ADateStart := ADate - DayOfWeek(ADate) + 2

else

ADateStart := ADate;

ADateEnd := ADateStart + 6; //周日

end;
:begin //月 xx-xx-01 to xx-yy-01

DecodeDate(ADate, myYear, myMonth, myDay);

ADateStart := StrtoDate(inttostr(myYear) + '-' + inttostr(myMonth) + '-01');

ADateEnd := incmonth(ADateStart);

end;
:begin //年 xx-01-01 to yy-01-01

DecodeDate(ADate, myYear, myMonth, myDay);

ADateStart := StrtoDate(inttostr(myYear)+'-01-01');

ADateEnd := StrtoDate(inttostr(myYear+1)+'-01-01');

end;

end;

end;

相关阅读 >>

如何在Delphi中禁用关于“返回值...可能未定义”的警告?

Delphi inputbox 输入时显示*号

Delphi 屏幕整体拉出源代码

Delphi webbrowser设置自己定义user-agent

Delphi ifdef 另类用法

Delphi tms web core messagedlg对话框用法

Delphi之木马生成原理(资源文件,和文件流的应用)

Delphi 调试tms web core应用

Delphi 用 gdi+ 给图片添加花边的例子

Delphi获取程序自身路径的函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...