1.我想取出DateTimePicker中选取的日期,将日期赋值到一个Label中,怎么取值啊?
2.假设我有两个DateTimePicker,分别选取了两个时间,我想算出这两个时间的相差天数,怎么算啊?如果能算的出,这个天数是什么型的啊?

解决方案 »

  1.   

    1 lable := DateToStr(DateTimePicker1.Date);
    2 tianshu := DateTimePicker1.Date - DateTimePicker2.Date; integer型
      

  2.   

    DateTimePicker.Date //取日期值
    DateTimePicker.Time //取时间值
    DateTimePicker.DateTime //取日期时间值.Int(DateTimePicker1.Date) - Int(DateTimePicker2.Date) //求两日期的相差在数.
      

  3.   

    1。Label1.Text = DateTimePicker1.Text
    2。Msgbox(DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value))
      

  4.   

    不好意思,刚才发错了。这是 VB.Net 的写法。该扁!
      

  5.   

    var
      Year, Month, Day: Word;
     begin
      Present:= Now;
      DecodeDate(DateTimePicker1.date, Year, Month, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
        + IntToStr(Month) + ' of Year ' + IntToStr(Year);
      

  6.   

    我用:
    DateTimePicker1.Date - DateTimePicker2.Date;
    好像不能直接相减的,用
    Int(DateTimePicker1.Date) - Int(DateTimePicker2.Date)
    也试过,可是都出错!
    为什么??