datetime好像是有年月吧?只有时-分-秒的字段类型是什么呢?

解决方案 »

  1.   

    有些数据库,分Date和Time两个类型,日期和时间是分开的,如DB数据库
    不过多数数据库都是DateTime合成一起的,如Access,SQl2000...
      

  2.   

    那是Time类型.
    2008-12-12 是Date类型;  转字符用TimetoStr();
    2008-12-12 12:12:12 是DateTime类型,  转字符用 DateTimeTostr(); 
    下面的详细:  六、日期函数
      对日期的处理,一般在有日期限制的共享、商业软件中经常使用到。如果你打算编写一款有日期限制的软件,熟悉使用下面的函数即可以实现。  1.Date
      功能说明:返回当前的日期。  参考实例:  procedure TForm1.Button1Click(Sender: TObject);  begin    Label1.Caption := ''今天是:'' + DateToStr(Date);  end;  Label显示为:今天是2005年1月1日。  2.DateToStr
      功能说明:将日期型转换为字符型。  参考实例:  var    S: String;  begin    S := DateToStr(Date);  end;  3.DateTimeToStr
      功能说明:将DateTime型转换为字符型。  参考实例:  var    S: String;  begin    S := DateTimeToStr(Now);  end;  4.DayOfTheMonth(所在单元:DateUtils)
      功能说明:获取指定日期的日。  参考实例:  Label1.Caption := IntToStr(DayOfTheMonth(Now));  假设当前日期为2005年1月2日,那么Label将显示为2。  5.DayOfTheWeek(所在单元:DateUtils)
      功能说明:根据指定日期,获取星期几。  参考实例:  Label1.Caption := IntToStr(DayOfTheweek(Now));  假设当前日期为2005年1月2日,那么Label将显示为7。根据返回的值来判断是周几。7表示星期天,1为星期一,依类类推。  6.DayOfTheYear(所在单元:DateUtils)
      功能说明:根据指定日期,获取天数。  参考实例:  Label1.Caption := IntToStr(DayOfTheYear(Now));  假设当前日期为2005年1月2日,那么Label将显示为2。表示是2005年的第2天。  7.DayOf(所在单元:DateUtils)
      功能说明:根据指定的日期,返回日。  参考实例:  Label1.Caption := IntToStr(DayOf(Date));  假设当前日期为2005年1月2日,那么Label将显示为2。  8.IsLeapYear
      功能说明:根据指定的年,判断是否为闰年。可使用YearOf函数获取年。  参考实例:  procedure TForm1.Button1Click(Sender: TObject);  begin    if IsLeapYear(YearOf(Date)) then ShowMessage(''是闰年'')    else ShowMessage(''不是闰年'');  end;  9.MonthOf(所在单元:DateUtils)
      功能说明:根据指定的日期,返回月份。  参考实例:  Label1.Caption := IntToStr(MonthOf(Date));  假设当前日期为2005年1月2日,那么Label将显示为1。  10.Now
      功能说明:返回当前日期及时间。  参考实例:  procedure TForm1.Button1Click(Sender: TObject);  begin    Label1.Caption := ''现在是:'' + DateTimeToStr(Now);  end;  11.YearOf(所在单元:DateUtils)
      功能说明:根据指定的日期,返回年。  参考实例:  Label1.Caption := IntToStr(YearOf(Date));  假设当前日期为2005年1月2日,那么Label将显示为2005。