F_GetMonthOfDOY

 

F_GetMonthOfDOY 1:

The function calculates the month from day number of the year.

FUNCTION F_GetMonthOfDOY: WORD

VAR_INPUT

VAR_INPUT
    wYear : WORD;(* Year: 0..2xxx *)
 wDOY : WORD;(* Year's day number: 1..366 *)
END_VAR

wYear: Year (0 ~ 2999).

wDOY: Day number of the year (1 ~ 366).

Return value

Description

0

Invalid wYear or wDOY parameter.

> 0

No error. Month (1 ~ 12)

Example:

PROGRAM P_TEST_DOY
VAR
    wYear       : WORD;
    wDOY        : WORD;
    wMonth      : WORD;
END_VAR
wYear := 2009;
wDOY := 31;
wMonth:= F_GetMonthOfDOY( wYear, wDOY );(* wMonth = 1 *)

wYear := 2009;
wDOY := 32;
wMonth := F_GetMonthOfDOY( wYear, wDOY );(* wMonth = 2 *)

wYear := 2009;
wDOY := 60;
wMonth := F_GetMonthOfDOY( wYear, wDOY );(* wMonth = 3 *)

Requirements

Development environment

Target System

PLC libraries to include

TwinCAT v2.10.0 Build > 1340
TwinCAT v2.11.0 Build > 1530

PC or CX (x86, ARM)

TcUtilities.Lib