zoukankan      html  css  js  c++  java
  • 日期选项

    // 根据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;

  • 相关阅读:
    Thinkphp回顾(五)之前台模板中的基本语法
    Thinkphp回顾之(四)查询方法深入学习
    Thinkphp框架回顾(三)之怎么实现平常的sql操作数据库
    Thinkphp学习回顾(二)之config.php的配置
    Thinkphp学习回顾(一)之基本结构目录
    端口
    curl put delete post get请求类型参数
    xshell连接virtualbox下的linux系统
    实现jsonp的三种方式
    匹配汉字
  • 原文地址:https://www.cnblogs.com/maweiwei/p/14734024.html
Copyright © 2011-2022 走看看