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!

Help display accurate time difference from 2 time fields 1

Status
Not open for further replies.

mvalley

Technical User
Mar 4, 2011
80
US
I have 2 fields that I need to show the difference in minutes.
{pat_out_of_room} and {proc_end}
When I do ({pat_out_of_room}-{proc_end}) the difference is displayed correctly most of the time.
Ex: proc end = 1002 Out of Room=1008 time displays 6

However if the time fields are different hours time is off
Ex proc end = 1258, Out of Room = 1309 time displays 51

I know there is an easy answer to this but I am having trouble remembering it. Any suggestions?
I am using Crystal 10
Thanks, Mary
 
If these fields are numbers intended to indicate HHmm, then you need to convert them to minutes, and then calculate. Create a formula:

numbervar ptout := (val(left(totext({pat_out_of_room},"0000"),2))*60)+(val(right(totext({pat_out_of_room},"0000"),2)));
numbervar prend := (val(left(totext({proc_end},"0000"),2))*60)+(val(right(totext({proc_end},"0000"),2)));
prend-ptout

-LB

 
Thank you, it was just what I needed. I was no where close to figuring this one out. This forum is great for newbies like myself. I appreciate everyones help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top