How can I retrieve date and time information from the system using the `DATE_AND_TIME` function?

Hello, I want to retrieve the date and time from the system using DATE_AND_TIME and only print the time using TIME_OF_DAY.

How to retrieve DATE_AND_TIME from the system?

Hi,

DATE_AND_TIME is a datatype, not a function.
Reading the PLCs date and time information, you can for example use DTGetTime(), which delivers the information as DATE_AND_TIME output.

https://help.br-automation.com/#/en/4/libraries%2Fastime%2Ffbks%2Fdtgettime.html

Best regards!

1 Like

DTGetTime() and DT_TO_TOD() together will give the TIME_OF_DAY as requested

1 Like

Time_Of_Day:=DT_TO_TOD(Date_and_Time); ifadesini kullandım ve zaman değiştiğinde saati alabiliyorum, ancak DTGet_Time.enable:=TRUE;
DTGet_Time();

Date_and_Time:=DTGet_Time.DT1;
Status:=DTGet_Time.status;

Time_Of_Day:=DT_TO_TOD(Date_and_Time);

ifadesi tarihi yanlış gösteriyor.

ā€œshows the date wrongā€ is not an error description and, like on other threads of yours where I already asked you, I would like you to think what information people might need to help you

I have set up an example locally and I see exactly the same time on the PLC, the DT output and the converted variable