Assigning and manipulating dates in ST

besaro

Member
Join Date
Mar 2016
Location
Skåne
Posts
2
Hello everyone.

I have a quick question regarding dates in Structured text.

What I´m trying to do is to take the current date, add/subtract days and save the result to a new variable.

I´m currently using "Date_and_timetocalendarstruct", to split the current date down to "current year", "current month", "current week" and so on.
I want to be able to, for example take the current date and subtract it by one (or any other number) and thus, generating a new date to store away for future use.

I have tried a couple of things so for, regarding applying arithmetic operations to dates, but without success. I hope someone here could point me in the right direction.

Thanks in advance :)
 
It will be easier to assist if you list what PLC system you are using. Different manufacturers have different abilities and methods available.
 
It will be easier to assist if you list what PLC system you are using. Different manufacturers have different abilities and methods available.


This particular scenario is in ABB,s 800xA systems and its configured against a AC 800M controller.
 
Thanks for responding with that. Unfortunately, I've never used ABB and their version of ST.

Something that I've done in the past using a Codesys implementation of ST is to take a date/time and turn it into a DINT that represented the amount of seconds since January 1, 1970. This was done using a builtin function. I then added or subtracted the number of seconds I wanted (1 day = 60 sec * 60 min * 24 hours = 86400 seconds) that that DINT value. Once I had this I then converted it back into the date/time using a related built-in function. The nice thing about this was that it automatically handled things like months with different lengths (March vs. April for example) and leap years. I didn't need to add in a bunch of weird case handling to do it.

You may find some of the libraries at Oscat (http://www.oscat.de/component/jdownloads/category/2-oscat-basic.html?Itemid=0) useful.
 

Similar Topics

Hello everyone, I've had this issue for the last 2 days where I try to assign the profisafe address to an IO block (6ES7 146-6FF00-0AB0) but when...
Replies
5
Views
207
I can't seem to figure out how to add descriptors to I/O points on an RMC using PCCU. Say, for example, I want to use "Valve_1" as a descriptor...
Replies
0
Views
84
Hello all. A little ashamed of myself that I can't remember how to do this but..... I have a 1734-AENT that I set the wheels to "888" applied...
Replies
9
Views
4,276
Hey everyone I'm working on a PLC project for a series of 4 vacuum pumps. I need to be able to rotate each pump into a different priority based on...
Replies
18
Views
6,521
Hi all, I am in the throes of commissioning a single S7-1517 cpu and I'm utilising both ethernet ports, X1 and X2, with individual IP addresses...
Replies
2
Views
1,747
Back
Top Bottom