Bojensen Blogs

Palle Agermarks Microsoft Dynamics AX blog: Find date using year and week as input

Today we needed an algorithm to calculate a date using only a year and a week number as input. As you may know different parts of the world has different rules for what week to consider as the first week of the year, so you have to be very careful when trying to write a generic algorithm.
In stead of being clever and figure this out ourselves, we decided that “AX knows best”. So basically we produce some dates and let AX tell us if they are in the week we are looking for.
The only part where we try to be clever is where we figure out what date to start asking on and not just start in the beginning of the year.

Here is what we came up with:

Any comments with better ideas are welcome. And well, in the end of the day we found that we didn’t need the algorithm anyway, but it was fun to think about how to do it.

Palle Agermarks Microsoft Dynamics AX blog: Find date using year and week as input

Comments are closed.