Simatic date compare

68FuryIII

Member
Join Date
Nov 2011
Location
Hämeenlinna
Posts
4
I have in Siemens TP270 output field "best before date" (yyyymmdd, DINT) and now i need to compare in plc (S7-400) that user can´t input date older or newer than 40 days. Any ideas how to do that o_O
 
Do you mean that the operator has to enter the date in the format "yyyymmdd" ? I.e. 20110821 for 2011-08-21 ?
If that is the case, I think it would be less error prone if you have separate inputs for year, month and day.
And does it have to be eaxctly 40 days ? If you can accept approximately 40 days, it becomes easier as you dont have to account for 28-30-31 days per month.
 
In the Standard Library you'll find under "IEC Function Blocks" FC34 - SB_DT_DT which allows you to subtract one date and time from another - that should cover what you need.
 
Do you mean that the operator has to enter the date in the format "yyyymmdd" ? I.e. 20110821 for 2011-08-21 ?
If that is the case, I think it would be less error prone if you have separate inputs for year, month and day.
And does it have to be eaxctly 40 days ? If you can accept approximately 40 days, it becomes easier as you dont have to account for 28-30-31 days per month.

Hi,
Yes operator has to enter date 20110821 for 2011-08-21. That 40 days is approximately. Its not exact.
 
In the Standard Library you'll find under "IEC Function Blocks" FC34 - SB_DT_DT which allows you to subtract one date and time from another - that should cover what you need.

Hi,
I tried FC34, but if i understand right FC34 difference output (TIME) works only for 24d_20H_31M_23S_647MS and after that result is always 0?
 
An idea.
First, check with FC34 if the difference output is greater than 24days. If yes, then subtract 24 days (FC35 SB_DT_TM), and again calculate the difference.
Then you can compare the difference with 16 days in stead of 40 days.
Not pretty but should work.
 
An idea.
First, check with FC34 if the difference output is greater than 24days. If yes, then subtract 24 days (FC35 SB_DT_TM), and again calculate the difference.
Then you can compare the difference with 16 days in stead of 40 days.
Not pretty but should work.

Good idea. I´ll try that at friday when i go back to work. Thank you for answers :)
 
Just a hint.
When using time and dates on the S7 systems, try and use BCD values, not INTs.
Makes it easier to manipulate and reference.
The (S)FC's also expect BCD values.
 

Similar Topics

Hello Experts, How can i update my offline Data Block to the Online Datablock without removing the offline comments? When i go online with the...
Replies
1
Views
3,575
I am unable to get a frimware update for the above mentioned hardware. After days of waiting and few emails back and forth to...
Replies
8
Views
4,614
We use profibus adapter from Eaton for MCCs. In the Simatic S7 there is one gsd file installed for this adapter. Since one of the adapter failed...
Replies
1
Views
2,138
Isn't it possible to update my simatic software (Step 7, wincc flexible and so on)??? What i am thinking of is a "live update", or what ever it...
Replies
3
Views
1,779
Hello.I'm using Simatic S7-300 PLC , Simatic operator panel OP 73 and wincc flexible. I have a problem regarding date & time on Simatic operator...
Replies
1
Views
3,540
Back
Top Bottom