AB Studio 5000 v31 - Compare Date/Time

Join Date
Oct 2021
Location
NC
Posts
9
Guys, beating my head on a wall here. I have two simple date-times and I want to find the oldest. Are there any better ways to do this beside a nested comparison? I have thought about changing to CurrentValue, but then I have to deal with the SIGN bit on the microseconds DINT which is also more effort then I really want to put in to this.

Am I missing a simpler way to compare two (or more) date times for oldest/youngest/etc? I got to be.... I must be over thinking something o_O
 
I did something similar that let you know if a date was beyond a set number of days (let say if a part was 30 days old or older, you deleted it from a database).

I believe I changed the date to a julian date (1 - 365), then did the normal compare for year and julian day.

For Time, I've always just multiplied the hours by 10000, hour by 100 and minutes by 1, added them all together and used 1 compare instruction.
A lot easier in an AOI too...
So 4:15:26pm (so 16:15:26) would convert to 161526 (you could put microsecond in decimal place by dividing by 1000)


Hope it helps.
 
Last edited:
On the Rockwell software web site they have a great set of free AOI for comparing date and time. They have LIM, GRT, GEQ, LES, LEQ, EQU etc all with the same format as the PLC clock.
There is even ADD and SUBtract.
 
lol.

Think through your microseconds concern: 1 million possible values need representation among a signed type’s positive range of ~2.147 billion.

Or: Generate a properly formatted string from the two, do a C-style strcmp.
 
Last edited:
Guys, beating my head on a wall here. I have two simple date-times and I want to find the oldest. Are there any better ways to do this beside a nested comparison? I have thought about changing to CurrentValue, but then I have to deal with the SIGN bit on the microseconds DINT which is also more effort then I really want to put in to this.

Am I missing a simpler way to compare two (or more) date times for oldest/youngest/etc? I got to be.... I must be over thinking something o_O


I think JaxGTO pointed out the simplest.



If your processor has LINT available, perhaps you could COP the DINT[2] WALLCLOCKTIME.CurrentValue or CST.CurrentValue to a single LINTs and compare those, although to be fair you still have the sign bit, unless you can COP to ULINTs.


Anything you do will want to be encapsulated in an AOI, which is why JaxGTO's suggestion is probably the best.
 
The 64-bit LINT data-type, introduced several years ago, is not supported in any current math instructions.

It's about as much use as a chocolate teapot....
 
What structure is the date/time currently stored? DINT[7] ?
An FSC would be pretty simple to compare each array element or part of the array.
zzz.png
 
On the Rockwell software web site they have a great set of free AOI for comparing date and time. They have LIM, GRT, GEQ, LES, LEQ, EQU etc all with the same format as the PLC clock.
There is even ADD and SUBtract.

JaxGTO is the winner! Glad somebody has wrapped that up into a AOI for others to use. Only dislike is that the AOI's take a custom "DateTime" data type where they could of made it work with the existing DINT arrary used by the GSV DateTime; All good. Thanks again.
 
lol.

Think through your microseconds concern: 1 million possible values need representation among a signed type’s positive range of ~2.147 billion.

Or: Generate a properly formatted string from the two, do a C-style strcmp.

Actually this is much more of a issue then you allude. The "microseconds" register actually can accumulate up to ~1.19 hours of "microseconds"; and in respect to a comparison, even "1" microsecond should be accounted for, no matter how miniscule it "seems". What's 1/1000 of an inch amongst friends? lol
 

Similar Topics

Hi everyone: I need to upgrade my Studio 5000 to from V31 to V33, but when I try to download from Rockwell PCDC, I only have the option up to 31...
Replies
4
Views
1,403
  • Poll
Hello Everyone, Is it a good idea to make the switch from 31.011 to 32 or 33? I am currently using 31.011 on all of our 5370 L33 or L36...
Replies
13
Views
7,785
When starting installation of Studio 5000 I get option to install it on C: disk as default. When I change it to disk D: I see that it still wants...
Replies
5
Views
2,952
I am trying to add datalinks to a couple of PF525 drives in studio 5000 V31 in order to use the PlantPax AOI. I am offline with the PLC and the...
Replies
8
Views
3,701
Hi, I've been working on a project for a couple of weeks now using Studio 5000 Logix Designer (v31 project, also have v32 and v21 installed)...
Replies
0
Views
2,204
Back
Top Bottom