Forum Discussion
6 Replies
- will_fetherolfContributor
According to this page (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/date-and-time-format-specifiers.html), the function returns 0-53 for week numbers. So, the week containing January 1 would be week 0. You're right, we're currently in week 18, but the conversion function will always return one less.
- tristaanogreEsteemed Contributor
nice, will_fetherolf! Then it's not a bug, just a misunderstanding of what's being returned.
so, %U will still work, you just need to make sure that you add 1 to any result to get the ISO standard week number.
However, it looks like %W is still what you're looking for. Just did a quick check and %W does it's numbering starting with 1 while %U numbers starting with 0. That's a documentation problem since %W also seems to note that the week numbering starts with 0.
In short... use %W to get the ISO standardized week number with weeks starting on Monday and numbering starting with 1.
- santoshthengeOccasional Contributor
Hello All,
Thank you for reply.
As per the previous conversion. You suggest use %W instead of %U.
But the %W formater also not working properly.
Please check the below image: %W formater for current year its working correctly but for next year its return wrong value
- will_fetherolfContributor
It's working correctly, it's simply 0-based. Add 1 to your result and you'll get the correct week number.
- tristaanogreEsteemed Contributor
Good catch... I'd open a ticket with smartbear at https://support.smartbear.com/message/?prod=TestComplete.
However, I wonder if it has to do with week numbering starting with Sunday versus starting with Monday. The first full week of 2018 started on Sunday, January 7th so the bug there might simply be having to do with when the week is listed as "starting.
Try using %W instead of %U. %W gives you the week number assuming weeks start on Monday instead of Sunday. That is giving the correct value of 18 for May 2nd.