Delphi Decimal Converter for Hours

Asked

Viewed 793 times

2

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

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;

Format option is interesting, because you manipulate which 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: http://www.delphibasics.co.uk/RTL.asp?Name=formatdatetime

Browser other questions tagged

You are not signed in. Login or sign up in order to post.