cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dennisb88
Resolver III
Resolver III

WeekNum(Today()) gives incorrect week number

Hi all,

 

I'm wondering why the formula: WeekNum(Today()) gives me to wrong week number.

It shows me today (2021-08-16) the week number: 34. That's not correct because it should be week number 33. 

Is this an error by PowerApps or do I something wrong?

 

I'm try also to get the week number by this formula: 

 

Value(If(DateDiff(DateValue(Txt_WkEnd.Text),DateAdd(Date(Year(DateValue(Txt_WkEnd.Text)),1,1),(8-Weekday(Date(Year(DateValue(Txt_WkEnd.Text)),1,1),Monday)),Days))>=0,If((RoundUp((DateDiff(Date(Year(DateValue(Txt_WkEnd.Text))-1,1,1),DateValue(Txt_WkEnd.Text),Days)+ (8-Weekday(Date(Year(DateValue(Txt_WkEnd.Text)),1,1),Monday)))/7,0))>53,1,(RoundDown((DateDiff(Date(Year(DateValue(Txt_WkEnd.Text))-1,1,1),DateValue(Txt_WkEnd.Text),Days)+ (8-Weekday(Date(Year(DateValue(Txt_WkEnd.Text)),1,1),Monday)))/7,0))),RoundDown((DateDiff(DateValue(Txt_WkEnd.Text),Date(Year(DateValue(Txt_WkEnd.Text)),1,1),Days)- (8-Weekday(Date(Year(DateValue(Txt_WkEnd.Text)),1,1),Monday)))/7,0)*-1))

 

Where "Txt_WkEnd.Text" has the value: today().

This results on (2021-08-16) in week number: 32, what's also incorrect.

 

Is there something wrong on the backend of PowerApps? 

Earlier this year all works fine and from my side noting has been changed.

 

Looking forwards to any suggestion.

1 ACCEPTED SOLUTION

Accepted Solutions
zmorek
Super User
Super User

You might need ISOWeekNum(), since this Jan 1 started on Friday, it's probably counting that as week 1.

 

"WeekNum starts with the week containing January 1, while ISOWeekNum starts with the first Thursday of the year. "


https://powerapps.microsoft.com/en-us/blog/power-fx-int-trunc-weeknum-and-isoweeknum-functions/

 

View solution in original post

2 REPLIES 2
zmorek
Super User
Super User

You might need ISOWeekNum(), since this Jan 1 started on Friday, it's probably counting that as week 1.

 

"WeekNum starts with the week containing January 1, while ISOWeekNum starts with the first Thursday of the year. "


https://powerapps.microsoft.com/en-us/blog/power-fx-int-trunc-weeknum-and-isoweeknum-functions/

 

View solution in original post

Hi @zmorek ,

 

Thanks! You're right! Is was missing the ISOWeekNum option! That's what I need!

 

Thanks again and have a nice day!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,904)