Date_To_BinaryTime6Day

Converts a date of type: DATE to the number of days since January 1, 1984 of type WORD. The function returns the value "0" if the date to be converted is before January 1, 1984.

Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)

Syntax

FUNCTION Date_To_BinaryTime6Day : WORD(0..16#AE35)
VAR_INPUT
    in     : DATE := D#1984-01-01;
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

Date_To_BinaryTime6Day 1: Inputs

Name

Type

Description

in

DATE

The date to be converted.

Date_To_BinaryTime6Day 2: Outputs

Name

Type

Description

bError

BOOL

The output is "TRUE" if the input value is smaller than "D#1984-01-01". In this case the function returns the value "0".

Date_To_BinaryTime6Day 3: Return value

Name

Type

Description

Date_To_BinaryTime6Day

WORD

Converted number of days since January 1, 1984. This value corresponds to the value of the T_BinaryTime.day component.

Sample

METHOD FINAL BinaryTime6Day_ToFrom_Date : BOOL
VAR
    tValue : T_BinaryTime;
    d      : DATE;
    sValue : STRING;
END_VAR

tValue.timeOfDay:=TOD#00:00:00.125;
tValue.day:=Date_To_BinaryTime6Day(D#1984-01-01);(* tValue.day:=16#0000 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#1984-01-01-00:00:00.125' *) 
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#1984-01-01 *)

tValue.timeOfDay:=TOD#01:02:03.125;
tValue.day:=Date_To_BinaryTime6Day(D#1984-01-02);(* tValue.day:=16#0001 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#1984-01-02-01:02:03.125' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#1984-01-02 *)

tValue.timeOfDay:=TOD#04:05:06.125;
tValue.day:=Date_To_BinaryTime6Day(D#2018-03-21);(* tValue.day:=16#30D2 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#2018-03-21-04:05:06.125' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#2018-03-21 *)

tValue.timeOfDay:=TOD#07:08:09;
tValue.day:=tValue.day + 7;(* add 7 days *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#2018-03-28-07:08:09' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#2018-03-28 *)

BinaryTime6Day_ToFrom_Date:=TRUE;