DATE_AND_TIME to date and time data in BCD format
DT_TO_DTBCD converts a value of the data type DATE_AND_TIME to a value of the data type DTBCD.
Input
date and time
Output
date and time in BCD format
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
bStart: BOOL:=FALSE;
DT_value: DATE_AND_TIME:=DT#2013-10-10-012:00:00;
DTBCD_value: DTBCD;
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_F,E_DT_TO_DTBCD!,,10,1,18,5,,?DEN?D?AENO?C);
B(B_VARIN,,DT_value,8,3,10,5,);
B(B_VAROUT,,DTBCD_value,18,3,20,5,);
B(B_CONTACT,,bStart,3,2,5,4,);
L(1,3,3,3);
L(5,3,10,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF bStart then
DTBCD_value := DT_TO_DTBCD(DT_value);
END_IF;