Sign In Help
Schneider Electric
HelpSign In
Schneider Electric Exchange
  • Home
  • Collaborate
  • Develop
  • Shop
Home Collaborate Develop Shop Log in or Register Help

Invite a Co-worker

Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel

Invitation Sent

Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
  • Home
  • Collaborate
  • Exchange Community
  • :
  • SCADA & Telemetry Solutions
  • :
  • Geo SCADA Expert Forum
  • :
  • Re: Structured Text - Need to Subtract 1y from DT in ST Logic
Community Menu
  • Forums
    • By Topic
        • EcoStruxure IT
          • EcoStruxure IT forum
        • Industrial Automation
          • Industry Automation and Control Forum
          • Alliance System Integrators Forum
          • Machine Solutions in the Digital Transformation
          • EcoStruxure Automation Expert / IEC 61499 Forum
          • Industrial Edge Computing Forum
          • Level and Pressure Instrumentation Forum
          • Modicon User Group
          • PLC Club Indonesia
          • SEE Automation Club Forum
          • Fabrika ve Makina Otomasyonu Çözümleri
          • Форум по промышленной автоматизации СНГ
        • SCADA & Telemetry Solutions
          • Geo SCADA Expert Forum
          • SCADA and Telemetry Devices Forum
        • Power Distribution IEC
          • Power Distribution and Digital
          • Power Standards & Regulations
          • Paneelbouw & Energie Distributie
        • Power Distribution Softwares
          • EcoStruxure Power Design Forum
          • SEE Electrical Building+ Forum
          • LayoutFAST User Group Forum
        • Solutions for your Business
          • Solutions for Food & Beverage Forum
          • Solutions for Healthcare Forum
    • By Segment
        • Food & Beverage
          • Solutions for Food & Beverage Forum
        • Healthcare
          • Solutions for Healthcare Forum
      • EcoStruxure IT
        • EcoStruxure IT forum
      • Industrial Automation
        • Industry Automation and Control Forum
        • Alliance System Integrators Forum
        • Machine Solutions in the Digital Transformation
        • EcoStruxure Automation Expert / IEC 61499 Forum
        • Industrial Edge Computing Forum
        • Level and Pressure Instrumentation Forum
        • Modicon User Group
        • PLC Club Indonesia
        • SEE Automation Club Forum
        • Fabrika ve Makina Otomasyonu Çözümleri
        • Форум по промышленной автоматизации СНГ
      • SCADA & Telemetry Solutions
        • Geo SCADA Expert Forum
        • SCADA and Telemetry Devices Forum
      • Power Distribution IEC
        • Power Distribution and Digital
        • Power Standards & Regulations
        • Paneelbouw & Energie Distributie
      • Power Distribution Softwares
        • EcoStruxure Power Design Forum
        • SEE Electrical Building+ Forum
        • LayoutFAST User Group Forum
      • Solutions for your Business
        • Solutions for Food & Beverage Forum
        • Solutions for Healthcare Forum
      • Food & Beverage
        • Solutions for Food & Beverage Forum
      • Healthcare
        • Solutions for Healthcare Forum
  • Blogs
    • By Topic
        • Industrial Automation
          • Industrial Edge Computing Blog
          • Industry 4.0 Blog
          • Industrie du Futur France
        • SCADA & Telemetry Solutions
          • SCADA and Telemetry Blog
        • Power Distribution IEC
          • Power Events & Webinars
          • Power Foundations Blog
        • Power Distribution NEMA
          • NEMA Power Foundations Blog
        • Power Distribution Softwares
          • EcoStruxure Power Design Blog
          • SEE Electrical Building+ Blog
        • Solutions for your Business
          • Solutions for Food & Beverage Blog
          • Solutions for Healthcare Blog
          • Solutions for Retail Blog
    • By Segment
        • Food & Beverage
          • Solutions for Food & Beverage Blog
        • Healthcare
          • Solutions for Healthcare Blog
        • Retail
          • Solutions for Retail Blog
      • Industrial Automation
        • Industrial Edge Computing Blog
        • Industry 4.0 Blog
        • Industrie du Futur France
      • SCADA & Telemetry Solutions
        • SCADA and Telemetry Blog
      • Power Distribution IEC
        • Power Events & Webinars
        • Power Foundations Blog
      • Power Distribution NEMA
        • NEMA Power Foundations Blog
      • Power Distribution Softwares
        • EcoStruxure Power Design Blog
        • SEE Electrical Building+ Blog
      • Solutions for your Business
        • Solutions for Food & Beverage Blog
        • Solutions for Healthcare Blog
        • Solutions for Retail Blog
      • Food & Beverage
        • Solutions for Food & Beverage Blog
      • Healthcare
        • Solutions for Healthcare Blog
      • Retail
        • Solutions for Retail Blog
  • Ideas
        • Industrial Automation
          • Modicon Ideas & new features
        • SCADA & Telemetry Solutions
          • Geo SCADA Expert Ideas
          • SCADA and Telemetry Devices Ideas
  • Knowledge Center
    • Building Automation Knowledge Base
    • Industrial Automation How-to videos
    • Ask Exchange
    • Digital E-books
    • Success Stories Corner
    • Power Talks
  • Events & Webinars
  • Support
    • User Guide
    • Leaderboard
    • Releases Notes
How can we help?
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
49243members
Join Now
242456posts
Join Now

Structured Text - Need to Subtract 1y from DT in ST Logic

Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Solved Go to Solution
Back to Geo SCADA Expert Forum
Solved
kvacola
Crewman kvacola
Crewman
‎2020-03-03 10:57 AM
0 Likes
5
1091
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 10:57 AM

Structured Text - Need to Subtract 1y from DT in ST Logic

[Using ClearSCADA 2017 R3]

 

I have a structured text program that is calculating a date and time from 2 FloBoss integers. INT1 is the Date (without year) and is a 4-digit value (e.g. 0226). INT2 is the 4-digit Time in 24h format (e.g. 1442). I've successfully gotten to the point in my ST program where I have the date. Unfortunately for dates that straddle the year for this device, I need to be able to subtract 1 year from the date. I use the current date and time to extract 'YEAR' and do a couple of concatenations to get the time:

 

 

dtDate		:= MAKE_DATE(YEAR, STRING_TO_SINT(strMonth), STRING_TO_SINT(strDay));
dtTime		:= MAKE_TIME_OF_DAY(STRING_TO_SINT(strHour), STRING_TO_SINT(strMins), 0, 0);	
DATETIME	:= CONCAT_D_TOD(dtDate, dtTime);

 

 

But the final function that compares the current time to the calculated time is giving me the error 'Program Error: Invalid conversion'

 

 

IF DATETIME > dtCurrentTime THEN
	DATETIME	:= SUB_DT_TIME(DATETIME, STRING_TO_TIME('D#1y'));
END_IF;

 

 

The program compiles just fine, I only get the error when I execute the program.

Solved! Go to Solution.

Labels
  • Logic
  • SCADA
Share
Reply

Accepted Solutions
AdamWoodland
Lt. Commander AdamWoodland Lt. Commander
Lt. Commander
‎2020-03-03 11:23 PM
0 Likes
0
1070
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 11:23 PM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

Might have been able to get away with:

 

DATETIME := SUB_DT_TIME(DATETIME, T#365d);

 

Although would need to take leap years into account.

See Answer In Context

Share
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
5 Replies 5
BevanWeiss
Admiral BevanWeiss
Admiral
‎2020-03-03 12:08 PM
0 Likes
4
1087
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 12:08 PM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

If these are all INTs... why are you doing anything with STRINGs?

 

CURR_INT1 := EXTRACT_DT_MONTH(NOW()) * 100 + EXTRACT_DT_DAY(NOW());

CURR_INT2 := EXTRACT_DT_HOUR(NOW()) *100 + EXTRACT_DT_MINUTE(NOW());



IF( CURR_INT1 > INT1 OR (CURR_INT1 = INT1 AND CURR_INT2 >= INT2)) THEN

    (* Our datetime event was this year.. *)

    (* We don't care about Seconds / Milliseconds, so set these to zero *)

    (* INT1 = MMDD, INT2 = HHMM *)

    DATETIME := MAKE_DATE_AND_TIME( YEAR, DIV( INT1, 100), MOD(INT1,100), DIV(INT2,100), MOD(INT2,100), 0, 0 );

ELSE

  (* our datetime event was last year *)

    (* We don't care about Seconds / Milliseconds, so set these to zero *)

    (* INT1 = MMDD, INT2 = HHMM *)

    DATETIME := MAKE_DATE_AND_TIME( YEAR - 1, DIV( INT1, 100), MOD(INT1,100), DIV(INT2,100), MOD(INT2,100), 0, 0 );



END_IF;

 

 

 


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Share
Reply
kvacola
Crewman kvacola
Crewman
‎2020-03-03 12:57 PM
0 Likes
3
1083
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 12:57 PM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

That did the trick! Thanks so much. I though I'd have to convert to strings to parse off the month/day and hour/min.

Share
Reply
AdamWoodland
Lt. Commander AdamWoodland Lt. Commander
Lt. Commander
‎2020-03-03 11:23 PM
0 Likes
0
1071
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 11:23 PM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

Might have been able to get away with:

 

DATETIME := SUB_DT_TIME(DATETIME, T#365d);

 

Although would need to take leap years into account.

See Answer In Context

Share
Reply
BevanWeiss
Admiral BevanWeiss
Admiral
‎2020-03-03 11:37 PM
0 Likes
1
1067
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-03 11:37 PM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

@kvacola How did you get somewhat good syntax colouring on your ST Logic text?  Did you have to colour it yourself?

 

@AdamWoodland It is a little frustrating that the logic engine (and many parts of ClearSCADA) can't do subtraction of things like months / years etc (conceptual time periods).  I was a bit afraid that 1year in days would overflow the holding of the 'Time' datatype.  What is the extent of what it can hold?


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Share
Reply
sbeadle
Sisko sbeadle Sisko
Sisko
‎2020-03-04 02:21 AM
0 Likes
0
1057
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content
‎2020-03-04 02:21 AM

Re: Structured Text - Need to Subtract 1y from DT in ST Logic

That was 'C' language colouring. Colours function names red but is unaware of  (* *) comments.

 

Time and its text representations support, for example, a century's worth of seconds in Adam's example.

Share
Reply
Top Experts
User Count
sbeadle
Sisko sbeadle Sisko
1
geoffpatton
Lieutenant geoffpatton
1
BevanWeiss
Admiral BevanWeiss
1
See More Top Experts
Find a Service Provider
Find a certified partner to help you address your integration, installation, maintenance and project needs.
View all Providers
Support

Have a question? Please contact us with details, and we will respond.

Contact Us
FAQ

Look through existing questions to find popular answers.

Learn More
About

Want to know more about Exchange and its possibilities?

Learn More

Full access is just steps away!

Join Exchange for FREE and get unlimited access to our global community of experts.

Connect with Peers & Experts

Discuss challenges in energy and automation with 30,000+ experts and peers.

Get Support in Our Knowledge Base

Find answers in 10,000+ support articles to help solve your product and business challenges.

Ask Questions. Give Solutions

Find peer based solutions to your questions. Provide answers for fellow community members!

Register today for FREE

Register Now

Already have an account?Log in

About Us FAQ Terms & Conditions Privacy Notice Change your cookie settings
©2020, Schneider Electric