My Time Field in my DBGrid is showing the date and time instead of time only - delphi

試著忘記壹切 提交于 2019-12-11 14:17:17

问题


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);

Submit to Database:

 tblbooking.FieldByName('Times').AsDateTime:=bookingtimes;

Example of DBGrid 'Times' column output:

12/30/1899 7:02:01AM

回答1:


If I understand what you mean this will work for you, just follow this steps:

  • This is your issue:

  • Double click on your table, and select Times field:

  • After you click on your field, go to the Object Inspector and find DisplayFormat property:

  • Write the format, in your case hh:mm:ss:

  • Now let's see the result:

That's it.



来源:https://stackoverflow.com/questions/46550892/my-time-field-in-my-dbgrid-is-showing-the-date-and-time-instead-of-time-only-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!