Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I extract just the time from a datetimepicker component in Delphi?

I have a datetimepicker component in a Delphi form and I would like to just get the Time. When i look at the date in debug mode I see 42544.621701, and I would like just to get 0.621701 without the date value.

like image 476
Juan Felipe Gomez Avatar asked Jun 29 '16 20:06

Juan Felipe Gomez


1 Answers

You can use the Frac() function:

var
  Time: TTime;
...
  Time := Frac(DateTimePicker1.DateTime);

Or, you can use the System.DateUtils.TimeOf() function, which is merely an inlined wrapper around Frac() with a more descriptive name:

uses
  ..., DateUtils;

var
  Time: TTime;
...
  Time := TimeOf(DateTimePicker1.DateTime);
like image 159
Ondrej Kelle Avatar answered Oct 31 '22 06:10

Ondrej Kelle