# Weekofyear is wrong for germany

**URL:** <https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445>\
**Category:** Windows\
**Created:** [May 19, 2021, 5:29pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445 "2021-05-19T17:29:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [May 19, 2021, 5:29pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/1 "2021-05-19T17:29:02Z")

</div>

the weekofyear seems wrong for germany, can somebody agree?  
at least at this one printed which hang at office wall show 17. and my calendar at home too.

```
Var d As New DateTime(2021,4,26,0,0,0,0) ' 26.04.2021
MessageBox "WeekOfYear = " + d.WeekOfYear.ToString + " (should be 17 not 18)"

```

Xojo 2021r1.1

Germany see Middle East, the international [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) standard

 ![IMG_20210519_193532_862](https://forum.xojo.com/uploads/default/original/2X/2/2c56280d141be8994096e96f8889599117693a4a.jpeg)

Web

 ![IMG_20210519_193343_657](https://forum.xojo.com/uploads/default/original/2X/8/8d0b97b2a543b6c8ee925733c4af8339e9f85566.jpeg)

Wiki

> Die **Kalenderwoche** ist nach ISO 8601 so definiert: **Kalenderwochen** haben 7 Tage, beginnen an einem Montag und werden über das Jahr fortlaufend nummeriert. Die **Kalenderwoche** 1 eines Jahres ist diejenige, die den ersten Donnerstag enthält.

> **[Week](https://en.wikipedia.org/wiki/Week)**
>
> A week is a unit of time equal to seven days. It is the standard time period used for short cycles of days in most parts of the world. The days are often used to indicate common work days and rest days, as well as days of worship. Weeks are often mapped against yearly calendars, but are typically not the basis for them, as weeks are not based on astronomy.
> The modern seven-day week can be traced back to the Babylonians, who used it within their calendar. Other ancient cultures had different we...

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [May 19, 2021, 5:52pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/2 "2021-05-19T17:52:37Z")

</div>

Cases:  
11024 - WeekOfYear not international savvy  
63292 - Weekofyear incorrectly calculated for 2021

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [May 19, 2021, 6:20pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/3 "2021-05-19T18:20:38Z")

</div>

> [@AlbertoD](#):
>
> Cases

great … 11 years or  
5 months later and nothing happened

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [June 27, 2021, 12:02pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/4 "2021-06-27T12:02:50Z")

</div>

Yes, hard to understand.  
There’s certainly a workaround by adding 1 if the day is Sunday, and finding which day number is the first Thursday, but I don’t see the point of having functions that won’t work outside of the USA (and that aren’t fixed 10 years later; I won’t believe each supported OS today doesn’t support internationalised dates out of the box)…

---

<div class="post-metadata">

**Author:** ![Michael\_Eckert](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_eckert/32/11196_2.png) [@Michael\_Eckert](https://forum.xojo.com/u/Michael_Eckert)\
**Post date:** [October 5, 2025, 9:28am UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/5 "2025-10-05T09:28:08Z")

</div>

Is there any reasonable workaround for this error?

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [October 5, 2025, 1:22pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/6 "2025-10-05T13:22:28Z")

</div>

> [@Michael\_Eckert](#):
>
> Is there any reasonable workaround

Yes, you can create code to handle this.

Back in 2021 we talked about this and there was some code shared in this topic:

> [@DateTime: No week 1 in 2021?](https://forum.xojo.com/t/datetime-no-week-1-in-2021/60088/):
>
> I have a web app (API 1.0, so Xojo 2019r3.2) with a custom calendar control based on DateTime (Yes, I know a plug in would be much wiser in terms of performance. For reasons unknown to me by customer request). I was just made aware that there is no week 1 when you cross next new year. Could it be that DateTime gets WeekOfYear wrong? The quick and dirty code that builds my date time array: Var firstDayOfMonth As DateTime = today.firstDayOfMonth Var FirstWeekDay As Integer = firstDayOfMonth.G…

---

<div class="post-metadata">

**Author:** ![Michael\_Eckert](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_eckert/32/11196_2.png) [@Michael\_Eckert](https://forum.xojo.com/u/Michael_Eckert)\
**Post date:** [October 5, 2025, 1:52pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/7 "2025-10-05T13:52:48Z")

</div>

Thank you!

I’ve tried your extend ISOWeekNumber and it works fine. My slightly adjusted version:

```auto
Public Function ISO8601WeekNumber(extends dt as datetime) As integer
  var curloc as locale
  
  curloc = curloc.current
  
  return dt.ToString("w",curloc).ToInteger
End Function

```

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [October 5, 2025, 7:36pm UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/8 "2025-10-05T19:36:10Z")

</div>

> [@Michael\_Eckert](#):
>
> I’ve tried your extend ISOWeekNumber and it works fine. My slightly adjusted version:
> 
> ```auto
> Public Function ISO8601WeekNumber(extends dt as datetime) As integer
> var curloc as locale
>   
> curloc = curloc.current
>   
> return dt.ToString("w",curloc).ToInteger
> End Function
> 
> ```

I’m glad I was able to help.

You can use this instead:

```auto
Public Function ISO8601WeekNumber(extends dt as DateTime) As Integer
  Return dt.ToString("w",locale.Current).ToInteger
End Function

```

---

<div class="post-metadata">

**Author:** ![Steve\_Wilson](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@Steve\_Wilson](https://forum.xojo.com/u/Steve_Wilson)\
**Post date:** [October 6, 2025, 6:49am UTC](https://forum.xojo.com/t/weekofyear-is-wrong-for-germany/63445/9 "2025-10-06T06:49:02Z")

</div>

SQLite has date functions which you can use:

```auto
SELECT strftime('%V', '2025-10-06') AS weekno

```
