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

Help With Conversion Formula

Status
Not open for further replies.

mgkSHA

Programmer
Jul 12, 2002
126
US
Hello:
I have been struggling to get a data conversion and group total for a while now. I am trying to take this one step at a time: I have a textfield or "string" which reads like a timer 00:23:45. I want to convert this into an integer so I can add these up,using the sum function. This is the formula I have tried in the field's "format" section. I tried to build this, but I keep getting an error. Can anyone, help. What am I doing wrong with this formula?

tonumber(left({ado.correctedduration} 2),mid({ado.correctedduration} 4,2),right({ado.correctedduration} 2))
 
well I assume you want to do math on the seconds shown by this string.

You were almost there with your formula, try this

@conversionToSeconds

WhilePrintingRecords;
numberVar result;

result := tonumber(left({ado.correctedduration},2))* 3600
+ tonumber(mid({ado.correctedduration},4,2)) * 60
+ tonumber(right({ado.correctedduration},2));

result;

Hope that works for you Jim Broadbent
 
Ngolem:

Yeah, I wrote a formula similar to that, but I kept getting the common error: "the ( is missing". I am a VB programmer and I have been "thrown into" Crystal reports, so I am learning while being on a tight deadline. Can you please help me understand how to iniate the formula you provided: OK, here is my question, I will break down your answer:

1)"@conversionToSeconds" - I assume this a new formula I will be creating, correct? This is simply the name I give the formula - - is this correct?

2)WhilePrintingRecords;
numberVar result; - OK, what is this and where does it go. Is this like a commented out reference or part of the code. Do I put this as the first two lines of my formula. I think this is where I am most lost.

3)result := tonumber(left({ado.correctedduration},2))* 3600
+ tonumber(mid({ado.correctedduration},4,2)) * 60
+ tonumber(right({ado.correctedduration},2));

result; - - now this code goes into the formula..correct? So basically, after I name my formula question 2 and 3 go into the formula builder in that order. Is that correct or am I missing something.

My final question..once I create this formula field where does it go? Does it go in the details section of my report, or is this the formula I put in my running total total field in the group footer? I REALLY appreciate your help. And if this code does go into the details section, what do I put in the running total field to get the sum of all newly created integers. Thanks again and please respond.

Martin K



 
1. this will NOT go in the "format" section.

2. this will be a real formula, that you create

* Insert, Field Objects, Formula Fields - create a new one, and the name will be @conversionToSeconds.


The body of the formula is this:

WhilePrintingRecords;
numberVar result;

result := tonumber(left({ado.correctedduration},2))* 3600
+ tonumber(mid({ado.correctedduration},4,2)) * 60
+ tonumber(right({ado.correctedduration},2));

result;

What this means -- you are creating a variable that is going to be evaluated at a specific time in the report so that it can be used for calculations --

3. this formula cuts up your seconds format and makes it into a number you can use for calculations (this is your conversion, not your totals or anything)

4. put this formula wherever your data is and then do your totals off of that --

I hope this helps in some way....



(create your totals using LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top