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

converting string HH:MM:SS to number of minutes

Status
Not open for further replies.

roody91

Technical User
Jan 16, 2002
21
0
0
US
I have a string field that shows hours, minues, seconds in the following format HH:MM:SS. This field does not map to an actual time format because the hours part could span tousands of hours ie a typical value could be 4458:32:00 which means 4,458 hours, 32 minutes, 0 seconds.
I would like to build a formula which I can use to strip out the hours and minutes values into seperate values which I can perfom a calcualtion to determine the total number of minutes. ie hours * 60 + the minutes value.
I've tried using the split command but I am not sure how I can extract the array elements into their own variable.

Anybody have any ideas on how to handle this?
 
Have you tried this yet:

Minute(Time({Table Value}))

The only thing that could mess this up would be if the Time() function crashed because of the large value, but I dont see why that would be. Nothing ever says that a time value can't have an obscene number of hours in it.
 
I've tried but this fails. 4458:55:00 is not a valid format for time. If I try ISTIME() crystal returns a false. I must find a way to strip out the value left of the first : as hours and the value between the first : and second : as the minutes.

 
Left({YourStingField},instr({YourStringField},":") will return everything to the left of the first colon. Then you can convert that to a number and multiply that by 60 to get total minutes.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
Mid("434534:23:32",InStr ("434534:23:32",":")+1,2)

As long as the minutes aren't more than 99 this works perfectly
 
Thanks for your help; before your reply I got this to work:


numberVar HH := ToNumber(Split({ClosedTkt.HO DUR}, ":", 3)[1]);
numberVar MM := ToNumber(Split({ClosedTkt.HO DUR}, ":", 3)[2]);

(HH * 60) + MM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top