Print Page | Close Window

Formula for converting to Hours,Mins and Secs

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13390
Printed Date: 04 May 2024 at 4:08pm


Topic: Formula for converting to Hours,Mins and Secs
Posted By: rkittu2k7
Subject: Formula for converting to Hours,Mins and Secs
Date Posted: 02 Jun 2011 at 12:44am
I have a field that is formatted as a time field which gives me the time in seconds only. I just need to know how to convert the seconds into hh:mm:ss format,how do I write a formula for converting the time kindly help me.

Thanks in advance
Ramakrishna Reddy



Replies:
Posted By: lockwelle
Date Posted: 02 Jun 2011 at 4:25am
local numbervar tme := {table.field};
local numbervar hr := 0;
local numbervar mn:=0;
local stringvar s;
local stringvar m;
 
hr := cint(tme/3600);
tme := tme - hr*3600;
mn := cint(tme/60);
tme:=tme - mn*60;
s:=totext(tme,0,"");
m:=totext(mn,0,"");
if tme<10 then s:="0"+s;
if mn<10 then m:="0" +m;
totext(hr,0,"")+":"+m+":"+s
 
 
HTH



Print Page | Close Window