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

Improving Syntax on this formula. 1

Status
Not open for further replies.

Crewdawg

Technical User
Oct 29, 2005
30
US
First off I want to say bear with me on this. I may leave out some key piece of information here so just post what other information you need to understand what I'm showing you.

This report shows our "Planned" and "Actual" times on individual jobs on a Work Order. It has a line for each job and then there is a Running Total on the bottom of the page. The problem is the database saves this "Time Field" (expressed as hh.mm) as a "Number Field". For example if we planned to put 3 hours and 30 minutes on a job the database stores this as 3.3. If we actuallu put 3 hours 37 minutes on the job the database stores this as 3.37. The formula I have included below works for a good estimate and tends to be fairly accurate when dealing with small workorders or individual numbers. The majority of work orders in which I need to use this report include a 1000 individual jobs. So after round several times on each line, and then doing a running talley on these 1000 lines, you can see why the reports can be hundreds of hours off when compared to the hard numbers.

The WOMNT_CARD.STANDARD_HOURS_DURATION field is where the database stores the "Planned Hours" for each particular card. The formula below is used on a report field named @PlannedMinutes (Number Field).

Code:
Round(Round ({WOMNT_CARD.STANDARD_HOURS_DURATION}, 0) + ((Remainder ({WOMNT_CARD.STANDARD_HOURS_DURATION}, 1) *100) / 60), 2)

I hope this makes sense to those reading. Your sugestions are greatly appreciated. As you can see by the images below the Planned total is only 18 hrs off, but the Actual total is 170hrs different.

This image is an example of what my Crystal Report generates.


This is an example of what my internal system generates.



----------------------------------------------------
Multithreading is just one thing after, before, or simultaneous with another.
 
Forgot to add CR 10. We are using a custom application for our Maintenance Tracking / Inventory / Acounting that is built on an SQL database. The system uses a custom reporting interface that doesn't meet our needs (or atleast the develepor doesnt support us in a way that it can work for us).

-Sean
 
Round ({WOMNT_CARD.STANDARD_HOURS_DURATION}, 0) is a bad formula. If you have 3 hours 51 mintes (3.51) then this will round to 4.

I would use this formula:

Code:
truncate({WOMNT_CARD.STANDARD_HOURS_DURATION})+round( ({WOMNT_CARD.STANDARD_HOURS_DURATION}-truncate({WOMNT_CARD.STANDARD_HOURS_DURATION}))/60,2)

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
I think you should convert the number field to minutes before summing (or using a running total). Try a formula like:

(truncate({table.number})*60)+(({table.number}-truncate({table.number}))*100)

Then when you have a summary, convert it into the hh:mm format, if you wish. Let's assume your summary is a running total {#minutes}. Then the conversion formula would look like:

totext(truncate({#minutes}/60),0,"")+":"+totext(remainder({#minutes},60),0,"")

If you want to use "." instead of ":" then substitute that in the formula.

-LB
 
Both of your posts were very helpful in getting me where I needed to be. I have been fretting over this formula for weeks and to think all I had to do was post this on Tek-Tips.com to get a resolution within hours. Now I just want to ask... what could I have done in my post to be more concice and still give you the information you needed.

-Sean
 
I would like to post a follow up to your formula lbass. How can I make it so the format on the field always shows as 00:00 even when it is empty. Currently a nill field shows as 0:0. As well as when it begins or ends in a zero.

Thanks in Advance
-Sean
 
Change it to:

totext(truncate({#minutes}/60),"00")+":"+totext(remainder({#minutes},60),"00")

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top