然后存到一个数组里, 我用两个DateTimePicker控件,请问如何实现?先谢了

解决方案 »

  1.   

    FormatDateTime('yyyymmdd', dtpDate.DateTime)
    格式化成字符串了,然后通过Copy方式分别Copy出年,月,日来
    FormatDateTime('hhmmss', dtpTime1.DateTime)
    方法同上
      

  2.   

    datautils单元中有很多关于此方面的函数,如YearOf(),DayOf.....
      

  3.   

    CTime dTime;
    dtpDate.GetTime(&dTime);
    int iYear=dTime.GetYear();
    int iMonth=dTime.GetMonth();
    int iDay=dTime.GetTime();
    ....
      

  4.   

    copy(str,m,n)
    其中str为要复制的字符串,从第m个字符开始,copy n个字符
    如copy('asdfg',3,2)的结果为df;
    不过delphi提供了好多有关时间的函数,可以直接使用
      

  5.   

    试试:FormatDateTime('yyyy', dtpDate.DateTime)
    FormatDateTime('mm', dtpTime1.DateTime);
    FormatDateTime('dd', dtpTime1.DateTime);
    FormatDateTime('hh', dtpTime1.DateTime)
      

  6.   

    var time: array[0..5] of integer;
    begin
    time[0]:=yaerof(DateTimePicker1.DateTime);
    time[1]:=MonthOf(DateTimePicker1.DateTime);
    time[2]:=dayof(DateTimePicker1.DateTime);
    time[3]:=HourOf(DateTimePicker1.DateTime);
    time[4]:=MinuteOf(DateTimePicker1.DateTime);
    time[5]:=SecondOf(DateTimePicker1.DateTime);end;要用到DateUtils单元,还有很多时间的函数,自己查帮助
      

  7.   

    可以这样
    formatdatetime('hh:mm:ss',dtpTime1.time);
      

  8.   

    呵呵,还是用DECODEDATETIME吧!!!!!!procedure DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word);DescriptionThe DecodeDateTime procedure breaks the value specified as the AValue parameter into Year, Month, Day of the month, Hour, Minute, Second, and MilliSecond values and returns these as the AYear, AMonth, ADay, AHour, AMinute, ASecond, and AMilliSecond parameters.我想只有用这个过程;了!!!
      

  9.   

    不过,你还要把,AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond 这些返回的变量进行数据类型转换一下!!!!!1
      

  10.   

    呵呵,楼上的都已经回答完了,
    就用 formatdatetime 来做吧!~~~~
    如果你不嫌麻烦
    FormatDateTime('yyyy', dtpDate.DateTime);
    FormatDateTime('mm', dtpDate.DateTime);
    FormatDateTime('dd', dtpDate.DateTime);
    FormatDateTime('hh', dtpDate.DateTime);//如果错误就用now 
    FormatDateTime('mm', dtpDate.DateTime);
    FormatDateTime('ss', dtpDate.DateTime);
      

  11.   

    呵呵,可是用DecodeDateTime()函数只要一句就可以了,楼主可以试一试!!!:)!
      

  12.   

    其实用 DecodeDateTime()就可以了
    然后你需要定义三个 word 类型的值来存放
    year,month,day
      

  13.   

    这个问题你问了很久了,还没解决吗,我认为我的方法 和formatdatetime
    都可解决呀!!!!
      

  14.   


    DecodeDateTime
    函数可以用。
      

  15.   

    你想不想用sql语句实现啊?
    使用DATEPART函数~
      

  16.   

    用DeCodeDate()和DeCodeTime()var
      Year, Month, Day, Hour, Min, Sec, MSec: Word;
    begin
      DecodeDate(DateTimePicker1.DateTime, Year, Month, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
        + IntToStr(Month) + ' of Year ' + IntToStr(Year);
      DecodeTime(DateTimePicker1.DateTime, Hour, Min, Sec, MSec);
      Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
        + IntToStr(Hour);
    end;
      

  17.   

    var
      Present: TDateTime;
      Year, Month, Day, Hour, Min, Sec, MSec: Word;
     begin
      Present:= Now;
      DecodeDate(Present, Year, Month, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
        + IntToStr(Month) + ' of Year ' + IntToStr(Year);
      DecodeTime(Present, Hour, Min, Sec, MSec);
      Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
        + IntToStr(Hour);
    end;