Delphi Convert from Decimal to Hours

2

I have the following decimal 0,0159722222222222 want to turn into hours in the following format 00:23:00 .

    
asked by anonymous 03.10.2016 / 22:18

1 answer

5

I know these options:

procedure TForm1.Button1Click(Sender: TObject);
var
  MyDate: TDateTime;
begin

  MyDate := 0.0159722222222222;

  //Com Cast
  ShowMessage(TimeToStr(MyDate));

  //Com Format
  ShowMessage(FormatDateTime('hh:nn:ss', MyDate));

end;

The Format option is interesting, because you manipulate what will be displayed:

Here are the options for the format:

y   = Year last 2 digits
yy  = Year last 2 digits
yyyy    = Year as 4 digits
m   = Month number no-leading 0
mm  = Month number as 2 digits
mmm     = Month using ShortDayNames (Jan)
mmmm    = Month using LongDayNames (January)
d   = Day number no-leading 0
dd  = Day number as 2 digits
ddd     = Day using ShortDayNames (Sun)
dddd    = Day using LongDayNames  (Sunday)
ddddd   = Day in ShortDateFormat
dddddd  = Day in LongDateFormat

c   = Use ShortDateFormat + LongTimeFormat
h   = Hour number no-leading 0
hh  = Hour number as 2 digits
n   = Minute number no-leading 0
nn  = Minute number as 2 digits
s   = Second number no-leading 0
ss  = Second number as 2 digits
z   = Milli-sec number no-leading 0s
zzz     = Milli-sec number as 3 digits

source: link

    
04.10.2016 / 13:17