如2004年的135天,求是2004年的几月几号!
求函数哦!!谢谢!

解决方案 »

  1.   

    如果是从:  2004年1月1日算起:select dateadd(day,135,'2004-01-01')
      

  2.   

    这样写:
    result := IncDay (StrToDate ('2004-1-1'),135);
      

  3.   

    写一个函数给你,测试通过!!参数说明:
    ============
    lpYear:年份,字符串类型,如'2005'
    lpIndex:第几天,如156function GetDateAt(lpYear: String; lpIndex: Integer): TDate;
    var
      lcDate: TDate;
    begin
      lcDate:= StrToDate(lpYear + '-1-1') + lpIndex -1;
      Result:= lcDate;
    end;调用示例:
    GetDateAt('2005', 155)
    返回的是2005年第155天的日期,TDate类型。
      

  4.   

    TDateTime dt;
    dt=EncodeDate(2004,1,1);//2004年第一天
    dt+=(135-1);            //第135天
    ShowMessage(dt);
      

  5.   

    你到DateUtil单元里面找找相关函数,里面提供了很多的时间函数
      

  6.   

    uses DateUtils;showmessage(datetimetostr(incday(strtodate('2004-1-1'),135)));
      

  7.   

    呵呵,不好意思写滴C++代码。
    不过要提一下的是上面朋友们写的代码:比如StrToDate('2004-1-1')需要当前操作系统的短日期格式为year-month-day或year-day-month(month=day=1),如果当前系统的分隔符为'/'时就会不认识。
    ==========================
    var
       dt:TDateTime;
    begin
       dt:=EncodeDate(2004,1,1);
       dt:=dt+(135-1);
       ShowMessage(DateToStr(dt));
    end;
      

  8.   

    如2004年的135天,求是2004年的几月几号!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    uses DateUtils;showmessage(datetimetostr(incday(strtodate('2004-1-1'),135)));//加135天,第136天
    showmessage(datetimetostr(incday(strtodate('2004-1-1'),134)));//加134天,第135天///
      

  9.   

    procedure TForm1.Button2Click(Sender: TObject);
    VAR
      sd,td:TDateTime;
      y,m,d:word;
    begin
      y:=2000;
      m:=11;
      d:=2;
      sd:=encodedate(y,m,d);
      td:=IncDay(sd,100);
      Label1.Caption:=DateTimeTostr(td);
    end;
      

  10.   

    看了,都是胡写的。看我的:
    function GetDate(year,days):TDateTime;
    begin
      result:=encodedate(year,1,1)+days-1;
    end;