Help on finding total hours in military time

snakes79

Member
Join Date
Nov 2015
Location
Illinois
Posts
17
Hello all. I have a user input 2 times per day, just the hour, (EX: 12 am or pm, 4 am or pm) I need help determining the total hours. For example: if a user enters 10 am, and 7 am, I need to determine 21 hours. Has anybody ever had to code something like this?

Platform: RS5000

Regards,

JF
 
It's the normal 24 hour clock to everyone outside of the US.

An yes, I've got some sample code for that. Let me dig it out
 
Hello all. I have a user input 2 times per day, just the hour, (EX: 12 am or pm, 4 am or pm) I need help determining the total hours. For example: if a user enters 10 am, and 7 am, I need to determine 21 hours. Has anybody ever had to code something like this?

Platform: RS5000

Regards,

JF

It is simple comparing

Easier if you change time values to 24hour format for calculation.
start_time: time 0..12 am or pm
stop time: time 0..12 am or pm
am_pm_start_sel: false = am, true = pm selected
am_pm_stop_sel: false = am, true = pm selected


if start time and am_pm_start_sel=false then
start time_temp:=start_time
end_if

if start time and am_pm_start_sel=true then
start time_temp:=start_time+12
end_if

if stop time and am_pm_start_sel=false then
stop time_temp:=stop_time
end_if

if stop time and am_pm_start_sel=true then
stop time_temp:=stop_time+12
end_if


if start_time_temp>stop_time_temp then
time_dif:=(24-start_time_temp)-stop_time_temp
end_if


if start_time_temp<=stop_time_temp then
time_dif:=stop_time_temp-start_time_temp
end_if
 
If he is logging on a windows pc....why not just change time format on pc to 24 hours?

I do not understand why the automation world does not standardize on 24 hour time, FAR easier to handle with data.
 
I am not sure how you are getting the user input. But I am assuming FactoryTalk HMI. If so:

I would use a control list selector in on HMI with 24 states to select time. That way when the user selects 7pm the value =19 7am the value = 7

If Start Time >= Stop Time
StartGEQ.jpg


If Start Time <= Stop Time
StartLEQ.jpg
 

Similar Topics

Hi all, I'm in the process of upgrading a PanelView1200 HMI program to be developed in FactroyTalk View Studio. The filetype for PanelView 1200...
Replies
7
Views
280
I have reached a dead end trying to find an EDS file. Manufacturer says to contact third party tech support. Clueless. RSLINX can see it, just...
Replies
9
Views
1,791
Hi, I work in a brewery in North Carolina and I need some help finding the output current for a VFD in the PLC. First off I am new to working with...
Replies
5
Views
1,326
Hi all, Where can I find the latest hardware series information on Rockwell's Literature library? Specifically a 1756-85E. I want to know the...
Replies
6
Views
1,959
Does anyone know where to find pre made circuit cards w/ toggle switches on them. Like those ones that the sales people would have on their test...
Replies
1
Views
983
Back
Top Bottom