// 根据cxCombox框选择,输出开始时间,结束时间
procedure GetCurSetDate(AcxCombobox: TcxCombobox; var AFromDate, AToDate: TcxDateEdit);
var
iYear, iMonth, iDay: Word;
iWeek: Integer;
CurDate, Dt: TDateTime;
begin
CurDate := StrToDateTime(Now10);
if AcxCombobox.ItemIndex = 0 then //今天
begin
AFromDate.Date := CurDate;
AToDate.Date := CurDate;
end
else if AcxCombobox.ItemIndex = 1 then //昨天
begin
AFromDate.Date := IncDay(CurDate, -1);
AToDate.Date := IncDay(CurDate, -1);
end
else if AcxCombobox.ItemIndex = 2 then //本周
begin
iWeek := DayOfWeek(CurDate) - 1;
AFromDate.Date := CurDate - iWeek + 1;
AToDate.Date := CurDate + 7 - iWeek;
end
else if AcxCombobox.ItemIndex = 3 then //上一周
begin
iWeek := DayOfWeek(CurDate) - 1;
AFromDate.Date := CurDate - iWeek + 1 - 7;
AToDate.Date := CurDate + 7 - iWeek - 7;
end
else if AcxCombobox.ItemIndex = 4 then //本月
begin
DeCodeDate(CurDate, iYear, iMonth, iDay);
AFromDate.Date := StrToDate(Format('%4d-%2d-01', [iYear, iMonth]));
AToDate.Date := IncMonth(AFromDate.Date, 1) - 1;
end
else if AcxCombobox.ItemIndex = 5 then //上一月
begin
Dt := IncMonth(CurDate, -1);
DeCodeDate(Dt, iYear, iMonth, iDay);
AFromDate.Date := StrToDate(Format('%4d-%2d-01', [iYear, iMonth]));
AToDate.Date := IncMonth(AFromDate.Date, 1) - 1;
end
else if AcxCombobox.ItemIndex = 6 then //本年
begin
DeCodeDate(CurDate, iYear, iMonth, iDay);
AFromDate.Date := StrToDate(Format('%4d-01-01', [iYear]));
AToDate.Date := IncYear(AFromDate.Date, 1) - 1;
end
else if AcxCombobox.ItemIndex = 7 then //去年
begin
Dt := IncYear(CurDate, -1);
DeCodeDate(Dt, iYear, iMonth, iDay);
AFromDate.Date := StrToDate(Format('%4d-01-01', [iYear]));
AToDate.Date := IncYear(AFromDate.Date, 1) - 1;
end
else if AcxCombobox.ItemIndex = 8 then //最近7天
begin
AFromDate.Date := IncDay(CurDate, -7);
AToDate.Date := CurDate;
end
else if AcxCombobox.ItemIndex = 9 then //最近1个月
begin
AFromDate.Date := IncMonth(CurDate, -1);
AToDate.Date := CurDate;
end
else if AcxCombobox.ItemIndex = 10 then //最近2个月
begin
AFromDate.Date := IncMonth(CurDate, -2);
AToDate.Date := CurDate;
end
else if AcxCombobox.ItemIndex = 11 then //最近3个月
begin
AFromDate.Date := IncMonth(CurDate, -3);
AToDate.Date := CurDate;
end;
end;
相关文章
- 11-01Flex 将默认日期格式转化成通用格式
- 11-01CodeGo.net>如何在SSIS中基于创建日期读取文件夹的所有文件?
- 11-01日期0701Python练习003
- 11-01sql 将8位字符串转换成日期型
- 11-01查看日期属性(休息日、节假日、星期几)[DAY_ATTRIBUTES_GET]
- 11-01【Teradata】tdlocaledef修改默认日期配置
- 11-01我可以使用seaborn在x轴上绘制带日期时间的线性回归吗?
- 11-01python-Seaborn distplot的权重选项?
- 11-01存储过程实现跳过节假日增加日期(原创)
- 11-01springMVC 前后台日期格式传值解决方式之二(共二) @InitBinder的使用