# Help with Progress code

I am using a Software called Epicor that uses Progress Open Edge or 4gl.  I am needing to do a rounding function on a number field that stores a "seconds since midnight value.  What I need to do is take that value and convert it to a decimal and then round it up to the nearest quarter hour for clockin and down to the nearest quarter hour for clockout.  What I have found is in the GUI if I take the number field And create a character calculated field I can translate the value to a time.  Here is an example of the code that works
String(Integer(LaborHed.Number01),"HH:MM")  This will give me the military time I am looking for but it is separated by a colon instead of a dot.  So 15:42 is what it may translate to but 15.42 is what I am looking for.  From there I need to take that value and round it up to the nearest quarter hour which would be 15.45 but do not know the syntax to do that.  I also have the ability to just write progress code but too much of a novice to be successful.  Hope anyone can help as manually updating 1500+ employees a day is wearing on me.
LVL 3
###### Who is Participating?

Database ExpertCommented:
We have to like below -

We can use IF / Case.

``````--

IF MOD(OurNumber, 10) < 0.26 THEN ( OurNumber -  MOD(OurNumber, 10) ) + 0.25
ELSE IF MOD(OurNumber, 10) > 0.25 AND MOD(OurNumber, 10) < 0.51 THEN ( OurNumber -  MOD(OurNumber, 10) ) + 0.50
ELSE IF MOD(OurNumber, 10) > 0.50 AND MOD(OurNumber, 10) < 0.76 THEN ( OurNumber -  MOD(OurNumber, 10) ) + 0.75
ELSE IF MOD(OurNumber, 10) > 0.75 THEN ( OurNumber -  MOD(OurNumber, 10) ) + 0.50

--
``````
1

Database ExpertCommented:

REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")

This will give u 15.45

Explanation - Replace function will search for : and if found it will replace it with the . as expected in the question.
0

IT DirectorAuthor Commented:
Thanks !!! That is great !!! Will try it now.
0

IT DirectorAuthor Commented:
Okay.  Tested and that fixes my  ":"  problem and changes it to decimal.  Awesome !!!  Now if we can just get the rounding function in there we will be Golden.  Will certainly give you credit for the help.  Thanks a million.  Is there a command for Ceiling like in Excel in Progress?  I can do it in microsoft excel but do not know the syntax in Progress.
0

Database ExpertCommented:
There are two functions in progress which can help us - Round and Truncate

can you give me a example what we have now and what is expected output.
0

IT DirectorAuthor Commented:
Using your suggestion.  REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")  on one record. Gives me.   15.19 as the result.  The value which is a number field represented as seconds since midnight is 55,165.  Since this needs to be expressed in quarter hours the ending result should be rounded up to the nearest quarter hour which would be 15.25
0

IT DirectorAuthor Commented:
You are Awsome !!!!
0

IT DirectorAuthor Commented:
Anything from .01 to .25 would round to .25.  Anything from .26 to .50 would be .50.  Anything from .51 to .75 would be .75 and anythig from .76 and up would round up.  Example on the last.   7.76 would round up to 8.00
0

Digital Marketing ExpertCommented:
You are Awesome  Pawan
0

IT DirectorAuthor Commented:
Fell asleep but just got your suggestion.  Trying that now.
0

IT DirectorAuthor Commented:
Getting Syntax Error.  What I did was replace "OurNumber"   with  "REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")" in the formula.  I have tried changing the field from text to decimal but still syntax error.  I have attached a screen shot
SyntaxError.docx
0

Database ExpertCommented:
Please let me know if below if working or not ?

ASSIGN knum = DECIMAL(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", "."))
0

IT DirectorAuthor Commented:
Yes it worked

Changed the calculated field type from Character to Decimal in the GUI and then put in this code.
Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", "."))

Reading into it I think I just add this as "OurNumber" in the formula above?
0

Database ExpertCommented:
Yes please replace the OurNumber with the new variable knum in the formula and it should work.
0

IT DirectorAuthor Commented:
Here is what I put in but still getting syntax error.  I wonder if my GUI does not understand the MOD function?

``````IF MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) < 0.26 THEN ( Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")) -  MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) ) + 0.25
ELSE IF MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) > 0.25 AND MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) < 0.51 THEN ( Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")) -  MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) ) + 0.50
ELSE IF MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) > 0.50 AND MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) < 0.76 THEN ( Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")) -  MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) ) + 0.75
ELSE IF MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) > 0.75 THEN ( Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")) -  MOD(Decimal(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", ".")), 10) ) + 0.50
``````
0

Database ExpertCommented:
Are you fine with SQL.
0

IT DirectorAuthor Commented:
Only interface I have to work with is this one which is Progress code I think.  Feel like it is so close  The database is sql but as I understand it uses Progress Open Edge to translate from Progress to SQL.
0

Database ExpertCommented:
please check if this is working..

``````ASSIGN knum = DECIMAL(REPLACE(String(Integer(LaborHed.Number01),"HH:MM") ,":", "."))
ASSIGN ref =  DECIMAL(MOD(knum, 1))
``````
0

IT DirectorAuthor Commented:
There is a "Modulo" command in there showing Modulo ( X modulo Y )  Is that the same as "MOD" ?
0

Database ExpertCommented:
I think it is different. Have u tried my last comment. is that worked?
0

IT DirectorAuthor Commented:
I will try your last comment.  I did not see it before.  It may take a bit as I have to go to a meeting but will be back in a bit.
0

Database ExpertCommented:
cool.
0

IT DirectorAuthor Commented:
Sorry for not getting back to you sooner.  Pulled many directions today.  Will hopefully get back to this tomorrow.  Thanks for all the help thus far as you have helped me almost all the way.  I had to go in an manually fix the payroll records which took quite a few hours.  I see on Experts-exchange you can be hired to help at 1.15/min.  Not sure how to do that but thinking doing a webex with you might get me there faster.
0

Database ExpertCommented:
>>I see on Experts-exchange you can be hired to help at 1.15/min
Sorry for few days I am NOT providing live help. Please try my last suggestion and we will fix all the issues we face. Thanks
0

IT DirectorAuthor Commented:
Understand.
0

IT DirectorAuthor Commented:
Not forgotten.  Just very busy.  Hope to get back to this week.
0

Database ExpertCommented:
That's fine. :)
0

IT DirectorAuthor Commented:
Thanks for the help.  Going ahead and giving credit with plans to come back to this at a later date.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.