Normal Topic Handling Time Fields (Read 1178 times)
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Handling Time Fields
Jun 23rd, 2006 at 12:23pm
Print Post Print Post  
I have two elements on my form, time started and time ended and then a total time field with the following code it works fine until The time goes past 1-hour then the results are not accurate, examples would be helpful.

Code: "If @IsBlank(Time on Job) then Time on Job = Time Ended - Time Started"

I have tried both time fields and number fields and used @ToNumber but have not received the results needed.

Thanks
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Handling Time Fields
Reply #1 - Jun 23rd, 2006 at 12:35pm
Print Post Print Post  
What is the desired result? Number of minutes (67)? Hours and minutes(1:07)? Something else?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Handling Time Fields
Reply #2 - Jun 23rd, 2006 at 1:26pm
Print Post Print Post  
Sorry about that, the total time field is then used to calculate the labor charge. so the results needed would be  1:15, hours and minutes.

Thanks
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Handling Time Fields
Reply #3 - Jun 23rd, 2006 at 3:33pm
Print Post Print Post  
Hello,

Is Time on Job bound to a time field?
If it is a time field, set the format to one of the 24 hour formats.

Or If Time on Job is bound to a text field then you need to divide the result of (Time Ended - Time Started) by 60 which gives you the hours and the remainder of (Time Ended - Time Started) divided by 60 is the number of minutes. Then string those two numbers together however you want and put the value in Time on Job.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Handling Time Fields
Reply #4 - Jun 23rd, 2006 at 4:26pm
Print Post Print Post  
Quote:
Hello,

Is Time on Job bound to a time field? No it is a number field.
If it is a time field, set the format to one of the 24 hour formats. That's the format I use.

Or If Time on Job is bound to a text field then you need to divide the result of (Time Ended - Time Started) by 60 which gives you the hours and the remainder of (Time Ended - Time Started) divided by 60 is the number of minutes. Then string those two numbers together however you want and put the value in Time on Job. Thanks I'll see what I can do with it.   Wink

-Ray

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Handling Time Fields
Reply #5 - Jun 23rd, 2006 at 4:32pm
Print Post Print Post  
Hello,

The Time on Job field needs to be either Text or Time. Number will not work for what you want, cause you actually have two numbers Hours and Minutes.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Handling Time Fields
Reply #6 - Jun 23rd, 2006 at 6:55pm
Print Post Print Post  
The field is a number field I have it formatted to 2 decimal places and no ",";
I just entered about 15 work orders and it worked perfectly. I can change it if you think it will be a problem down the road.

Thanks for all the help !!
Smiley
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Handling Time Fields
Reply #7 - Jun 23rd, 2006 at 8:12pm
Print Post Print Post  
Off the top of my head, here is a formula I have used in the past to calculate Elapsed Hours with fractions. 
As I recall, this wil work even when StartTime is PM and EndTime is AM of the next day.

StartTime is a Time field.
EndTime is a Time field.
ElapsedHours is a Number field, I use 2 decimals.

//Calculate hours difference, convert into minures, convert into hours.
ElapsedHours = @MOD( EndTime - StartTime, 1440) / 60

Answer is in Hours and fractions, so 2.25 is 2 hours and 15 mins, not 25 minutes.

Hope this was helpful.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: Handling Time Fields
Reply #8 - Jun 23rd, 2006 at 8:35pm
Print Post Print Post  
Thanks Bob, I just added the code to my code database.

Wink
  
Back to top
 
IP Logged