cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dennisb88
Responsive Resident
Responsive Resident

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/

 

dennisb88
Responsive Resident
Responsive Resident

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
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,326)