CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Mon Feb 24, 2020 8:43 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Jan 02, 2020 11:14 pm 
Offline

Joined: Wed Jan 16, 2019 7:18 pm
Posts: 13
I need to be able to generate a specific DATE_AND_TIME value. The user will input the Month, Day and Hour as integers, and the program will work out the Year.

I am having trouble figuring out how to do this. I tried generating a string, and then converting the string to a DATE_AND_TIME variable. There appears to be a STRING_TO_DT function, but it does not seem to work, and I see nothing in the help files that actually references it.

Any ideas on how to do this would be great.

_________________
Tim Manning


Top
   
PostPosted: Fri Jan 03, 2020 10:09 am 
Offline

Joined: Sun Jun 28, 2015 12:23 pm
Posts: 99
Hello Tim
Add the library DTUtil. Some good stuff in there.
Or before I found this library, I wrote this FB...(PLCOpenImport)
Attachment:
PLC090419_1.xml

ph


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Jan 03, 2020 2:48 pm 
Offline

Joined: Wed Jan 16, 2019 7:18 pm
Posts: 13
Thanks. I actually got my code to work just now. The STRING_TO_DT function does work, you just have to make sure the string is formed properly, and includes all the right things. I was missing the 'DT#' at the beginning of the string.

I will take a look at what you sent and the DTUtil library.

_________________
Tim Manning


Top
   
PostPosted: Thu Jan 09, 2020 7:35 pm 
Offline

Joined: Fri Feb 16, 2018 5:39 pm
Posts: 45
This is the library "CAA DTUtil Extern" correct?

I will also have to look at that library, thanks. What I currently do is use the CONCAT function to add the appropriate formatting to various strings before converting them. I can never trust people to enter the correct format if it includes things like t# even if the dialogue windows informs them of the correct formatting they can't be trusted.

Edit: Ah yes I already had the library installed because the 3S library "Time and Date 3.5.7.0" installs it. It looks like the functions DTConcat and DateConcat and really all of the rest as well are super helpful. I can testify that the function blocks

GetTimeZoneInformation
SetTimeZoneInformation
GetDateAndTime
SetDateAndTime

Are also super useful for setting the time and date from within the visualizations rather than having to set it on the OS.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited