2-595
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Time and Time of Day Instructions
2
GetWeekOfYear
GetWeekOfYear
The GetWeekOfYear instruction gets the week number for the specified year, month, and day of month.
* If you omit the input parameter, the default value is not applied. A building error will occur.
The GetWeekOfYear instruction gets the week number for the year, month, and day of month specified
in In. Weeks are counted from Monday to Sunday. The count is incremented when changing from Sun-
day to Monday.
January 1 is always in week 1. For example, if January 1 is a Thursday, January 1 to January 4 (Sun-
day) is week 1 and January 5 (Monday) to January 11 (Sunday) is week 2.
The following example is for when In is D#2011-2-1.
Instruction Name FB/FUN Graphic expression ST expression
GetWeekOfYear Get Week Number FUN Out:=GetWeekOfYear(In);
Variables
Name Meaning I/O Description Valid range Unit Default
In Year,
month, day
Input Year, month, day Depends on data type. Year, month,
day
*
Out Week Output Week number 1 to 54 Week
---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In OK OK
Out OK
Function
(@)GetWeekOfYear
EN ENO
In Out
abc:=GetWeekOfYear(D#2011-2-1);
D#2011-2-1
LD ST
abc
GetWeekOfYear
EN ENO
In
D#2011-2-1
USINT#6
Out=abc
In
Week number
Week