DBGrid中的“我的时间”字段显示的是日期和时间,而不是仅显示时间-Delphi [英] My Time Field in my DBGrid is showing the date and time instead of time only - delphi
问题描述
我的数据库中有一个名为时间的字段,它是日期/时间格式,其格式设置为短时间。在我的数据库中,日期不显示,也不据我所知被添加到数据库中。它只是时间值。我的DBGrid显示带有时间值和日期 12/30/1899的时间字段。如何清除时间字段中的日期。
I have a field in my database called 'Times', it's a date/time format and its format is set to 'short time'. In my database the date does not show, nor is it being add to the database as I know. It is only the time value. My DBGrid shows the time field with the time value and the date '12/30/1899'. How do I get rid of the date in my time field.
这是我用来提交到数据库的代码。
获取时间值:
Here is the code I used to submit to the database. Get time value:
bookingtimes:= timeof(dttime.Time);
提交到数据库:
tblbooking.FieldByName('Times').AsDateTime:=bookingtimes;
DBGrid时间列输出示例:
Example of DBGrid 'Times' column output:
12/30/1899 7:02:01AM
推荐答案
如果我了解您的意思,这将对您有用,请按照以下步骤操作:
If I understand what you mean this will work for you, just follow this steps:
- 这是您的问题:
- 双击表,然后选择
Times
字段:
- Double click on your table, and select
Times
field:
- 单击字段后,转到
对象检查器
并找到DisplayFormat
属性:
- After you click on your field, go to the
Object Inspector
and findDisplayFormat
property:
- 编写
格式
,在您的情况下为hh :mm:ss
:
- Write the
format
, in your casehh:mm:ss
:
- 现在让我们来看看结果:
就是这样。
这篇关于DBGrid中的“我的时间”字段显示的是日期和时间,而不是仅显示时间-Delphi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!