Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert 75.75 to HH:MM:SS

Status
Not open for further replies.

MARTINRODDY

Programmer
Apr 3, 2001
30
US
Hi there,

I am trying to convert a value like '75:04' (being 75 mins 04 secs) to HH:MM:SS format...............If anyone can offer help i would be gratful. Thanks
Martin
 
If you are always going to have that format, you could do something like this:

function ReformatTime(aTime: string): string;
var
SeparatorPos: longint;
Minutes: longint;
Seconds: longint;
newTime: TDatetime;
begin
SeparatorPos := Pos(':',aTime);
Minutes := StrToIntDef(Copy(aTime,1,SeparatorPos-1),0);
Seconds := StrToIntDef(Copy(aTime,SeparatorPos+1,length(aTime),0);
newTime := EncodeTime((Minutes div 60),(Minutes mod 60), Seconds,0);
Result := FormatDateTime('hh:nn:ss',newTime);
end;

Note: I haven't compiled it! Bugs are possible! But that's an idea.
TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top