[英]My Time Field in my DBGrid is showing the date and time instead of time only - delphi
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'.
我的DBGrid显示带有时间值和日期'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);
Submit to Database: 提交到数据库:
tblbooking.FieldByName('Times').AsDateTime:=bookingtimes;
Example of DBGrid 'Times' column output: DBGrid“时间”列输出示例:
12/30/1899 7:02:01AM
If I understand what you mean this will work for you, just follow this steps: 如果我了解您的意思,这对您有用,请按照以下步骤操作:
Times
field: Times
字段: Object Inspector
and find DisplayFormat
property: Object Inspector
并找到DisplayFormat
属性: format
, in your case hh:mm:ss
: format
hh:mm:ss
: That's it. 而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.