delphi:从数据库中查出来的值能定义格式吗

来源:百度知道 编辑:UC知道 时间:2024/09/28 10:57:36
从数据库中把记录查出来显示在dbgrid中,select * from tablename 因为记录中有日期和时间两个字段,日期读出来是正确的,格式是:2009-03-13,但时间格式是:1899-12-30 上午 11:35:00,进入数据库中日期显示的也是2009-03-13,但时间显示的是:上午 11:35:00,为什么会多出个1899,能不能在上面的查询语句中规定下格式,让查出来的时间能显示为11:35

这个是SQL SERVER里边测试得到的。
你看看。

date:类型tdatetime;值:'2008/01/21'

select convert(nvarchar,date,1) from table
返回格式:01/21/08

select convert(nvarchar,date,2) from table
返回格式:08.01.21

select convert(nvarchar,date,3) from table
返回格式:21/01/08

select convert(nvarchar,date,4) from table
返回格式:21.01.08

select convert(nvarchar,date,5) from table
返回格式:21-01-08

select convert(nvarchar,date,6) from table
返回格式:21 01 08

select convert(nvarchar,date,7) from table
返回格式:01 21, 08

select convert(nvarchar,date,8) from table
返回格式:00:00:00

select convert(nvarchar,date,9) from table
返回格式:01 21 2008 12:00:00:000AM

select convert(nvarchar,date,10) from table
返回格式:01-21-08

select convert(nvarchar,date,11) from table
返回格式:08/01/21

select convert(nvarchar,date,12) from table
返回格式:08