比如取系统时间date或now所在月的月末日期。如2003-6-25--->2003-6-30

解决方案 »

  1.   

    楼上的那个只能在oracle使用。要是在其它数据库中必须使用:
    1。求出当前月的下一月
    2。求出下一月的第一天的前一天
    这样才能获得答案。
      

  2.   

    完整解决方案:Form1上加三个Edit,一个Buttonprocedure TForm1.Button1Click(Sender: TObject);
    var
      Present,EndMonth: TDateTime;
      Year, Month, Day,EndY, EndM, EndD: Word;
    begin
      Present:=DtTmPckPDate.Date;
      Edit1.Text:=DateToStr(Present);
      DecodeDate(Present, Year, Month, Day);
      if Month>1 then
      EndMonth:=strtodate(inttostr(Year)+'-'+inttostr(Month-1)+'-'+'1')
      else
      EndMonth:=strtodate(inttostr(Year-1)+'-'+'12'+'-'+'1');
      Edit2.Text:=DateToStr(EndMonth);
      DecodeDate(EndOfTheMonth(EndMonth),EndY, EndM, EndD);
      Edit3.Text:=inttostr(EndY)+'-'+inttostr(EndM)+'-'+inttostr(EndD);end;
      

  3.   

    var
      AYear,AMonth,ADay: Word;   //uses DateUtils
    begin
      DecodeDate(now,AYear,AMonth,ADay);
      EndOfAMonth(AYear,AMonth);  //这就是你要的结果
    end;
      

  4.   

    哇噻,wongang兄好厉害。其实我就是想求上月的月末,操作数据库用,谢谢!
    同样谢谢各位兄弟。
      

  5.   

    抗议,我给出的是delphi的函数,郁闷!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!