Tenho o seguinte decimal 0,0159722222222222
quero transformar em horas no seguinte formato 00:23:00
.
1 Resposta
Conheço essas opções:
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;
A opção do Format é interessante, por você manipular oque será exibido:
Aqui estão as opções para o 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
fonte: http://www.delphibasics.co.uk/RTL.asp?Name=formatdatetime