11-01-2022 12:16 AM
I have week Number 44 and year is 2022.
How to convert this week Number into month??
Solved! Go to Solution.
11-01-2022 01:39 AM
Hi Risuraj,
@Risuraj wrote:
I have week Number 44 and year is 2022.
How to convert this week Number into month??
By applying some simple math!
What have you tried?
Where are you stuck?
Why don't you attach your current VI?
Generic advice: we don't solve your homework for free…
11-01-2022 06:54 AM
@Risuraj wrote:
I have week Number 44 and year is 2022.
How to convert this week Number into month??
This problem cannot be solved using the information given. Please refer to https://en.wikipedia.org/wiki/ISO_week_date
Alternatively, you could approximate the month like this: (44/52*12)+0.5. This turns out to be end of October and seems to be a decent approximation.
11-01-2022 10:51 AM - edited 11-01-2022 10:52 AM
@LLindenbauer wrote:
@Risuraj wrote:
I have week Number 44 and year is 2022.
How to convert this week Number into month??
This problem cannot be solved using the information given. Please refer to https://en.wikipedia.org/wiki/ISO_week_date
Alternatively, you could approximate the month like this: (44/52*12)+0.5. This turns out to be end of October and seems to be a decent approximation.
I agree. You'd think it is a trivial thing, but the definition of the number of weeks in a year is surprisingly complicated.
11-01-2022 12:13 PM
I once thought it would be smart to just let .NET do the heavy lifting. As it turns out, even Microsoft did not get it right the first time: https://learn.microsoft.com/en-us/archive/blogs/shawnste/iso-8601-week-of-year-format-in-microsoft-n...
11-01-2022 01:51 PM
A Gregorian year is 52.1775 weeks long,
whereas a tropical year is 52.1773768865 week long.
11-02-2022 05:27 AM
On top of all the complexities mentioned, I'm sure a week can be in two months.
11-02-2022 02:51 PM - edited 11-02-2022 02:56 PM
It can.
The answer can be found here but it uses .NET to do the math. I've done it but I am sure you can use LabVIEW to get the answer without using .NET Constructor/Property/Invoke nodes.
11-03-2022 04:18 AM
@Eric1977 wrote:
It can.
The answer can be found here but it uses .NET to do the math. I've done it but I am sure you can use LabVIEW to get the answer without using .NET Constructor/Property/Invoke nodes.
Well, not that much wrong with .NET...
The calculations get complex at CultureInfo.CurrentCulture.Calendar, there you get rules for the week numbering... Guess you could dig into that too.
Here's an untested conversion of the start:
11-03-2022 07:25 AM - edited 11-03-2022 07:45 AM
Your code is MUCH MORE ELEGANT than mine is. 😂 But, I've used .NET to do all the work and followed the C# code in the link I provided.