?
Solved

Convert String to Number Field

Posted on 2010-11-15
10
Medium Priority
?
1,002 Views
Last Modified: 2012-05-10
I have a the below formula that is erroring out because it states that the third field is a string, not a number (even though it is a number, it's classified as a string for some reason.

({multdely.duedate}-{schjob.totlabour}+{schpri.priority})*1000

Now I made another formula to convert it to a to a number using tonumber({schpri.priority})

When I replace the third field with the code, it tells me that everything in the parentheses needs to be a currency or a number amount.

({multdely.duedate}-{schjob.totlabour}+{@Pri_Num_Convert})*1000

What am I doing wrong?
0
Comment
Question by:Zkdog
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34139713
It seems like you are subtracting a number from a date.

You cannot do that. You need to subtract number from number and date from date.

(date2-date1+1) * daterate

date2-date1 gives you number of days difference and you add 1 to get number of days and them multiply by the rate per day to get the wage.
0
 
LVL 1

Author Comment

by:Zkdog
ID: 34139905
I am trying to subtract a number from a date and understand what you are saying but the solution is off I think.   {schjob.totlabour} is actually the total time, in days, numerically that it would take complete said job. So I would need something like.....
(({multdely.duedate}-{schjob.totlabour}) +{Formula}))*1000.  Would that be correct?
0
 
LVL 1

Author Comment

by:Zkdog
ID: 34140064
Ok just got done talking with some higher ups and we can actually drop the Formula*1000 part entirely.

So basically what I need now is ({multdely.duedate}-{schjob.totlabour}).  Essentially I need to subtract hours from a date I believe.  I'm thinking the way to do this would be convert the duedate field over to a number similiar to a Julian Date Number and then subtract the number of hours from it.  Or possibly if I can find a field that includes date AND time for the due date and subtract the hours from it?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 101

Expert Comment

by:mlmcc
ID: 34140081
A Date - Days is still a date.

What is the formula trying to calculate?

mlmcc
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34140183
You can subtract days from date or date from another date.

date-numeric = date
date-date = numeric

for the formula you need to work on numbers.

so first get the number of days and then multiply to get whatever you need.

You don't need Julian. Date can do it.

? CTOD("12/31/2010")-DATE() gives you days to Christmas.

Hope this made it easy.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34140195
I meant New Year Eve not Christmas.
0
 
LVL 12

Expert Comment

by:jrbbldr
ID: 34140285
Try doing the work in small pieces to find out precisely what is wrong.

Set up your data tables as needed and then from your VFP Command window try:
   ?{multdely.duedate}-{schjob.totlabour}
Does that error out?

If not then try
   FirstValue = ({multdely.duedate}-{schjob.totlabour})
   ?TYPE('FirstValue')
   ?FirstValue  +  {schpri.priority}
Again, does that error out?

Going on until you either get it working or determine what the precise error is.....
   SecondValue = FirstValue  +  {schpri.priority}
   ?TYPE('SecondValue')
   ? SecondValue  *1000

Another alternative would be to insert a SET STEP ON into your code just before the execution of the code in question.    
Then use the TRACE Window to examine the contents of each field in question BEFORE the code line executes.

Also...  
Now I made another formula to convert it to a to a number using tonumber({schpri.priority})
   ToNumber()   ???
That is not a VFP function.  
Did you create your own Function using the VFP Functions  VAL() and maybe INT() ?
 
Good Luck
0
 
LVL 1

Author Comment

by:Zkdog
ID: 34140358
mlmcc: Essentially an arbitrary number to schedule and sort operations by.  We need DueDate - Total Labour(in hours).   The number can be in any format as it will be supressed and is just for sorting purposes.

CaptainCyril: This looks like it may work. I'm not sure, however what you mean by the ? CTOD part of the formula.  I didn't find any commands similiar to it.  If I used ({multdely.duedate} -  DATE("Jan 1, 2010")) would return say, 345 then subtract say 1.2 (totlabour) returning 343.8?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 34140569
Try this

DateAdd('h',-{TotalLaborField},{DueDateField})

mlmcc
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34142824
Total Labour is that a number meaning hours? If you subtract it from a Date which is DueDate then the result is a date and you can't multiply a date with another number.

({multdely.duedate}-{schjob.totlabour}+{schpri.priority})*1000

From what I understand from you

duedate is a date
totlabour is a numeric
priority is a string

You need an operation on 2 dates to get a number.
To conver a string to a number you use VAL(priority)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question