News:

  • June 09, 2026, 09:40:35 AM

Login with username, password and session length

Author Topic: military time coversion  (Read 7285 times)

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
military time coversion
« 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?

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: military time coversion
« Reply #1 on: November 19, 2017, 02:41:27 PM »
Try IF(C30,(V1+12)%24,V1)

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Re: military time coversion
« Reply #2 on: November 19, 2017, 03:01:40 PM »
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.