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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting minutes into days/hours/minutes

Status
Not open for further replies.

DLTaylor

MIS
Dec 17, 2003
51
GB
Hi

I have a value in minutes and I want to display this as days/hours/minutes. Is there a formula that will do this?

I also need to get a total in days/hours/minutes for several records - so want to be able to add any number of records and get a total time.

I am using crystal 7.

Thanks.
 
Local NumberVar TotalMins := 1440;
Local NumberVar Days := 0;
Local NumberVar Hours := 0;
Local NumberVar Mins := 0;
Days := Truncate(Truncate(TotalMins/60)/24);
Hours := Remainder(Truncate(TotalMins/60),24);
Mins := Remainder(TotalMins,60);
totext(Days,0,"")&" day(s) "&totext(Hours,0,"")&" hour(s) "&totext(Mins,0,"")&" min(s)";

Replace the item in bold with your field.

synapsevampire has a faq related to this faq767-3543



Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
Thanks for this. I have tried it but am getting an error which says 'The remaining text does not appear to be part of the formula'. It highlights the problem as being with the & on the last line of the formula.

Thanks.
 
Which & ?

Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
The first one in the last line of the formula:

totext(Days,0,"")&" day(s)
 
Do you have the complete :

totext(Days,0,"")&" day(s) "&totext(Hours,0,"")&" hour(s) "&totext(Mins,0,"")&" min(s)";

in the last line, or just :

totext(Days,0,"")&" day(s)

If the latter, it needs to be totext(Days,0,"")&" day(s)"

It works ok in my testing....

Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
No I've got the complete thing:

totext(Days,0,"")&" day(s) "&totext(Hours,0,"")&" hour(s) "&totext(Mins,0,"")&" min(s)";

I'll have another look at it.

Cheers.
 
ToText((Truncate(Sum ({HISTORY_DETHIST_.QUANTITY})/24)),0) + " days, " +
ToText((Remainder (Sum ({HISTORY_DETHIST_.QUANTITY}), 24)),0) + " hours "


Don't know if this will help you, but I use this formula for a quantity field that I want turned into days and hours. The result looks like (17 days, 4 hours). Sometimes I can figure something out by looking at other formulas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top