我如何从datetimepicker的值中得到月份数值啊?
我用MONTHOF()函数,可编译出错,说,没定义此函数,请指点。
语句如下:
sql.add('select * from baobiao where rq=:a');
params[0].asinteger:=monthof(datetimepicker1.datetime);
错误:没有定义monthof

解决方案 »

  1.   

    formatdatetime('m',datetimepicker1.datetime)
      

  2.   

    decodedate(datetimepicker1.datetime,iyear,imonth,iday);
      

  3.   

    DateTime: TDateTime;
    DateStr,tempStr:string;
    MonthValue:integer;  DateTime := Now;                 //返回当前日期时间
      DateStr:= DateToStr(DateTime);   //转换日期为字符串01/12/99
      tempStr:=substring(DateStr,4,2));//从DateStr的第4个字符处返回2个字符
      MonthValue:=strtoint(tempStr);
      

  4.   

    谢谢,用此过程可行decodedate()
    liujinping(金龟子) 你的办法我也试过,不过就是在DELPHI中无substring此函数,不过应该有另外此功能的函数,你的思路想想也是可行的。
      

  5.   

    substring是sql的函数,delphi 的用copy