zoukankan      html  css  js  c++  java
  • delphi 如何判断两个时间日期间隔 是否为整月?

    2016-07-01~~2016-07-31  整月
    2016-08-05~~2016-08-31  非整月
    2016-09-12~~2016-09-30  非整月
    2016-02-01~~2016-02-26  非整月

    就是这个意思,如何搞?

    注意要USES   DateUtils单元;

    procedure TMDI_1_1_Frm.Button8Click(Sender: TObject);
    var S,Date1,Date2:string;
    begin
      S:='2016-08-05~~2016-08-31';
      Date1:=Copy(S,1,10);
      Date2:=Copy(S,13,10);
      if (StartOfTheMonth(StrToData(Date1))=StrToData(Date1)) and
         (EndOfTheMonth(StrToDate(Date2))=StrToData(Date1))
        then showMessage('整月!')
        else showMessage('非整月!')
    end;
     
    或者
     
    var
      sdate,date1,date2:string;
    begin
      sdate:='2016-02-01~~2016-02-28';
      Date1:=Copy(Sdate,1,10);
      Date2:=Copy(Sdate,13,10);
      if (dayof(strtodate(date1))<>1or  (dayof(incday(strtodate(date2)))<>1)
      then
        showmessage('非整月')
      else
        showmessage('整月');
    end;
     
     
     
      
     
      
     
     
     
     
     
      
     
     
  • 相关阅读:
    突破
    leetcode刷题 538~
    leetcode刷题 519~
    Docker练习之镜像更新方法1
    十二 Linux之tar解压缩
    十一 Linux软件包管理yum
    十 Linux指令之grep
    九 linux指令之find
    八 Linux ps指令查看进程和kill杀进程
    七 Linux top命令
  • 原文地址:https://www.cnblogs.com/lantianhf/p/6037376.html
Copyright © 2011-2022 走看看