Host Engineering Forum
General Category => General Discussion => Topic started by: PLCGuy on November 19, 2017, 01:31:43 PM
-
Here is the situation. Not everyone knows how to deal with military time.
So I used a math box to convert standard time to military time to deal with the UDT in the plc. All is good up to midnight.
What I have is they can enter in 5 for the hour. That goes to V1. Then I have a button to select AM or PM. C30 on for PM. The results goes to V100. That is now 17. I use that number for my UDT stuff. I wrote if(C30,V1+12,V1). Problem is 12 AM is midnight which is Zero. I can not figure out how deal with 12 plus 12 = 24. I need to change it to Zero for UDT to work.
FYI minutes is coming in on V2. I load them both into UDT1.hour and UDT1.Minutes.
Am I making this too complicated?
-
Try IF(C30,(V1+12)%24,V1)
-
wow, that works. I would have never thought of that.
the only thing not working is if someone enters zero and presses PM. I can just not allow zero in the data entry. Or do something when zero is entered.
thank you.