[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
????????0:begin??//日
??????????ADateStart?:=?ADate;
??????????ADateEnd?:=?ADate?+?1;
????????end;
????????1:begin??//周??DayOfWeek()?Sunday?=1
??????????if?DayOfWeek(ADate)<>2?then??//?<>?Monday
????????????ADateStart?:=?ADate?-?DayOfWeek(ADate)?+?2
??????????else
????????????ADateStart?:=?ADate;
??????????ADateEnd?:=?ADateStart?+?6;??//周日
????????end;
????????2:begin??//月?????xx-xx-01??to?xx-yy-01
??????????DecodeDate(ADate,?myYear,?myMonth,?myDay);
??????????ADateStart?:=?StrtoDate(inttostr(myYear)?+?'-'?+?inttostr(myMonth)?+?'-01');
??????????ADateEnd?:=?incmonth(ADateStart);
????????end;??????????????????????????
????????3: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;
轉載于:https://www.cnblogs.com/derod/archive/2009/08/03/1537359.html
總結
以上是生活随笔為你收集整理的[Delphi]根据输入日期按年月周日输出日期段的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 转:VC6.0与VC.net的具体区别
- 下一篇: 职场智慧之如何提升自己在公司的价值