规则如下:
        从指定日期 ~ 第二年指定日期前一天 合同年第1年
        从第三年指定日期 ~ 第四年指定日期前一天 合同年第2年
        ......(依此类推)
例:
一客户XX公司
签定合同日期为:2003-01-18 
那么:2003-01-18 ~ 2004-01-17 :合同年第1年
      2005-01-18 ~ 2006-01-17 :合同年第2年
      2007-01-18 ~ 2008-01-17 :合同年第3年
      2009-01-18 ~ 2010-01-17 :合同年第4年
      2011-01-18 ~ 2012-01-17 :合同年第5年
其中签定合同日期知道但不固定
如果给定日期 DT=2003-01-01 则在 不在合同年内
             DT=2003-02-20 则在 合同年第1年
             DT=2004-02-18 则在 不在合同年内
             DT=2009-01-19 则在 合同年第4年内

解决方案 »

  1.   

    IncYear 
    Returns a date shifted by a specified number of years.UnitDateUtilsCategorydate/time routinesfunction IncYear(const AValue: TDateTime; const ANumberOfYears: Integer = 1): TDateTime;
      

  2.   

    合同年第n年:
    AValue:=StrToDate('2003-01-18');
    BValue:=IncYear(AValue, n);//加n年
    CValue:=IncYear(BValue, 1)-1;//加1年减1天
      

  3.   

    你的定义有问题。
    --------------------------
    那么:2003-01-18 ~ 2004-01-17 :合同年第1年  //2004-01-18  ~  2005-01-17 到哪儿去了 
          2005-01-18 ~ 2006-01-17 :合同年第2年  //类似
          2007-01-18 ~ 2008-01-17 :合同年第3年
          2009-01-18 ~ 2010-01-17 :合同年第4年
          2011-01-18 ~ 2012-01-17 :合同年第5年
    其中签定合同日期知道但不固定
    如果给定日期 DT=2003-01-01 则在 不在合同年内
                 DT=2003-02-20 则在 合同年第1年
                 DT=2004-02-18 则在 不在合同年内  //??
                 DT=2009-01-19 则在 合同年第4年内 //??
      

  4.   

    xxmmmx(踢踏) ,我的定义没问题啊,我的意思,是如何判断一日期是否在指定日期开始的时间段内啊?
      

  5.   

    TO xxmmmx(踢踏) ,你没有理解我的意思,
    AValue:=StrToDate('2003-01-18');
    BValue:=IncYear(AValue, n);//加n年
    CValue:=IncYear(BValue, 1)-1;//加1年减1天
    固然好求,但如何判断是否在有效的时间段范围
      

  6.   

    TO xxmmmx(踢踏),难道你的合同年有一年没一年??
    这是游戏规则,不需要去管,只需要根据规则去游戏就对了,
      

  7.   

    哈哈,我已经解决了,还得谢谢xxmmmx(踢踏)的热心关注!!!!