From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate Week number

Hello,

does anybody have an Lookout object which cold calculate the current week
number within the year at any moment ? Or maybe have some examples how to
create this inside Lookout ?

Thanks a lot,
Roman
0 Kudos
Message 1 of 5
(4,219 Views)
"Roman" wrote:
>>Hello,>>does anybody have an Lookout object which cold calculate the current
week>number within the year at any moment ? Or maybe have some examples how
to>create this inside Lookout ?>>Thanks a lot,>Roman
0 Kudos
Message 2 of 5
(4,219 Views)
Hi Roman,

You could use a counter that updates every year and start in 36526 which
correspont to Jan/1/2000. Use a pulse or TimeOfDay as parameter for your
Today(logical) function. The week number is gonna be:
Mod((Today(logical) - 36526)/7)
This should work.
"Roman" wrote:
>>Hello,>>does anybody have an Lookout object which cold calculate the current
week>number within the year at any moment ? Or maybe have some examples how
to>create this inside Lookout ?>>Thanks a lot,>Roman
0 Kudos
Message 3 of 5
(4,219 Views)
Sorry, In my previous message I used the wrong function. If you want to get
the number of week you have to get the integer of the division by 7 and not
Mod. So the expression should be:
int((Today(logical) - 36526)/7).
"Carlos Barberino" wrote:
>>Hi Roman,>>You could use a counter that updates every year and start in
36526 which>correspont to Jan/1/2000. Use a pulse or TimeOfDay as parameter
for your>Today(logical) function. The week number is gonna be:>Mod((Today(logical)
- 36526)/7)>This should work. >"Roman" wrote:>>>Hello,>>does
anybody have an Lookout object which cold calculate the current>week>number
within the year at any moment ? Or maybe have some examples how>to>create
this inside Lookout ?>>
Thanks a lot,>Roman
0 Kudos
Message 4 of 5
(4,219 Views)
Carlos,

Your Expression assumes that the week starts on a Saturday (36526th day is
Saturday January 1st, 2000) but doesn't accommodate for it. So, to account
for the first week, the following Expression will work (for only a year though!):

((today(logical)-36520)/7)+1

Ciao!

Khalid


"Carlos Barberino" wrote:
Sorry, In my previous message I used the wrong function. If you want to get
the number of week you have to get the integer of the division by 7 and not
Mod. So the expression should be:

int((Today(logical) - 36526)/7).



>"Carlos Barberino" wrote:>>>Hi Roman,>>You could
use a counter that updates every year and start in>36526 which>correspont
to Jan/1/2000. Use a pulse or TimeOfDay as param
eter>for your>Today(logical)
function. The week number is gonna be:>Mod((Today(logical)>- 36526)/7)>This
should work. >"Roman" wrote:>>>Hello,>>does>anybody
have an Lookout object which cold calculate the current>week>number>within
the year at any moment ? Or maybe have some examples how>to>create>this inside
Lookout ?>>Thanks a lot,>Roman
0 Kudos
Message 5 of 5
(4,219 Views)