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;

  • 相关阅读:
    pycharm在401跑程序需要每个py文件加一句
    youtube下载视频方法
    服务器重启登陆界面死循环
    matlab2012b_win_install
    ubuntu_matlab2012b_install
    cuda8.0 + cudnn6 + tensorflow1.4 xing
    [BAT] cmd 管理员权限 右键菜单 运行
    Windows下遍历所有GIT目录更新项目脚本
    获取Xshell Xftp等官网下载地址
    Win10 企业版 激活 批处理
  • 原文地址:https://www.cnblogs.com/maweiwei/p/14734024.html
Copyright © 2011-2022 走看看