我使用datetimepicker 只需将取得的年月日存入数据库中,但是它把时间也存入了如何才能只存日期就好了
   还有就是如何计算出 2个用datetimepicker取得的日期所间隔的天数多谢了....

解决方案 »

  1.   

    1,这是数据类型的问题,不是datetimepicker的问题
    2,直接相减
      

  2.   

    Returns the number of whole days between two specified TDateTime values.Unit
    天数:
    DateUtilsCategorydatetime routinesDelphi syntax:function DaysBetween(const ANow, AThen: TDateTime): Integer;DescriptionCall DaysBetween to obtain the difference, in days, between two TDateTime values.DaysBetween counts only whole days. Thus, DaysBetween reports the difference between Dec 31, 1999 11:59 PM and Jan 1, 2000 11:58 PM as 0 because the difference is one minute short of an entire day.
    如果是SQL SERVER的话,时分秒是去掉的,实在是讨厌时分秒,用字符字段代替时间字段!
      

  3.   

    上面最后一句话有误!
    如果是SQL SERVER的话,时分秒是去不掉的,实在是讨厌时分秒,用字符字段代替时间字段!
      

  4.   

    1.把datetimepicker的值Formatdate('yyyy-mm-dd',datetimepicker.date)后给源赋值.
    2.给你函数:
    function DayDiff( d1, d2 : TDate ):integer;
    var
      nYear1, nMonth1, nDay1 : Word;
      nYear2, nMonth2, nDay2 : Word;
    begin
      DecodeDate( d1, nYear1, nMonth1, nDay1 );
      DecodeDate( d2, nYear2, nMonth2, nDay2 );  result := Trunc( EncodeDate(nYear1, nMonth1, nDay1) -
          EncodeDate( nYear2, nMonth2, nDay2 ) );
    end;