02-06-2019 05:01 PM
Thanks Kyle, I'm going to run with your %U +1 option and get 6 out of 7 years right.
Thanks again for all the quick replies!
Doug
02-06-2019 05:04 PM
To be fair that was Altenbach's solution, I just pointed out that 1/7 years it would fail.
Schedule time in January of 2023 now to patch the program 🙂
02-06-2019 05:07 PM
Thanks, I updated both of your comments as solutions because it's important to know there are some limitations.
02-06-2019 05:15 PM
@Kyle97330 wrote:
The ISO 8601 standard for weeks states that “week 1” is the first week of the year with a Thursday in it. Not sure if that's exactly what you want, but it would be nice if LabVIEW had that as an option.
If you are willing to use .NET there's an function that's more along the lines of what you need, with some configurable parameters to refine it:
Interesting.
I would say that LabVIEW doesn't implement that defintion.
Format Codes for the Time Format String
<%U> | week number of the year (00–53), with the first Sunday as the first day of week one; 00 represents the first week |
<%W> | week number of the year (00–53), with the first Monday as the first day of week one; 00 represents the first week |
For %U (week starts on Sunday)
1/1/19 (A Tuesday) yields 00 because Week 1 starts on Sunday 1/6/19
1/1/18 (A Monday) yields 00 because Week 1 starts on Sunday 1/7/19
1/1/17 (A Sunday) yields 01 because Week 1 starts on Sunday 1/1/19
By the ISO 8601 standard, all 3 of those would be week 1 since they are all in the same week with a Thursday. (Friday 1/1/xx and Saturday 1/1/xx would not be.)
02-06-2019 05:22 PM
Wow!
Makes you wonder how come it's so easy for websites to pull the Week of the year. There must be a PHP function or something that helps pull the week so easily.
<?php
$ddate = "2012-10-18";
$date = new DateTime($ddate);
$week = $date->format("W");
echo "Weeknummer: $week";
https://www.timeanddate.com/date/weeknumber.html
02-07-2019 10:13 AM - edited 02-07-2019 10:21 AM
@Kyle97330 wrote:
The ISO 8601 standard for weeks states that “week 1” is the first week of the year with a Thursday in it. Not sure if that's exactly what you want, but it would be nice if LabVIEW had that as an option.
I'm sure there exist definitions for this somewhere, that involve every possible weekday as being the first week of the year. ISO basically just assumes that the first week in a year is the first week that has at least four days, considering Monday to be the starting point for a week. This leaves out areas on the globe that consider the week to start on Sunday!. But all of these are basically as arbitrary as any other definition.
Unfortunately ISO isn't a standard officially sanctioned outside of the EU for most things, although it gets more and more considered as a valid recommendation even in the former "empire" areas. But the standards in programming come from the second half of last century when ISO was often seen as just a bunch of creators of difficult and mostly useless standards.
02-08-2019 02:16 AM
@rolfk wrote:
@Kyle97330 wrote:
The ISO 8601 standard for weeks states that “week 1” is the first week of the year with a Thursday in it. Not sure if that's exactly what you want, but it would be nice if LabVIEW had that as an option.
ISO basically just assumes that the first week in a year is the first week that has at least four days, considering Monday to be the starting point for a week.
I've only heard the "first week with four days" definition, but that equates to there being a Thursday, I like that wording. 🙂
/Y
02-08-2019 12:43 PM
@Yamaeda wrote:
I've only heard the "first week with four days" definition, but that equates to there being a Thursday, I like that wording. 🙂
/Y
There are several mutually equivalent and compatible descriptions of "week 01" as the ISO spec defines:
A sufficiently creative person could come up with a few more, probably.
04-05-2019 06:16 AM - edited 04-05-2019 06:18 AM
Hello,
It would be possible to have the VI with the .NET Calendar getWeekOfYear converted to Labview 2017 ?
Thanks for who can help.
08-13-2019 06:33 AM - edited 08-13-2019 06:37 AM
Sorry for sharing for any years not valid code. Here is the new one.
Condition: First week of year must have 4 days at least to mark them as 1, otherwise 0 (thu, fri, sat, sun for %W and wed, thu, fri, sat for %U).
Repaired: Missing Pad using zero when formatting week number back to string.