web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to get the current...
Power Automate
Unanswered

How to get the current week number in Power Automate?

(1) ShareShare
ReportReport
Posted on by 18

Hi everyone,

I'm trying to get the current week number in Power Automate (cloud), but I keep running into issues with invalid expressions. I tried using but all are wrong

formatDateTime(utcNow(), 'ww') = semaine "ww" (wrong)
add(div(dayOfMonth(utcNow()),7),1) = semaine 3 (wrong)
add(div(dayOfMonth(utcNow()),7),0) = semaine 2 (wrong)
add(div(dayOfYear(utcNow()),7),1)= semaine 2 (wrong)

However, this doesn't seem to work as expected. It either returns "ww" as text or causes an error.

Does anyone know the correct expression to get the current week number in Power Automate? Ideally, I want a simple and reliable solution that works within a Compose action.

I ask ChatGPT et Copilot to help me but they didn't find (i try youtube too but the same thing, nothing works)

Thanks in advance!

Categories:
I have the same question (7)
  • Verified answer
    David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    You can use this expression: formatNumber(add(div(dayOfYear(triggerBody()['date']),7),1),'00')       
     
    Replace triggerBody()['date'] with your date file, which looks like you want to use utcNow(). If run on today's date, it returns 08, which according to Week number, would be correct.
  • CF-19021403-0 Profile Picture
    18 on at
    Hi David,
     
    Thanks a lot for your answer, It seems to be working.
     
    I just used utcNow() instead of triggerBody()['date'].
     
    I'll wait until next month to confirm, but it looks good so far.
     
    Thanks again for your help (I think this could be useful for others as well.)
     
    Have a great day!
  • CF-19021403-0 Profile Picture
    18 on at
    I have a second euqtion about that : 
     
    Now that i can change the number of the week automaticaly in the title on email, i would like rename my file
     
    exemple : "Sheet_Time_S##" with ##= number of the week à sent the email and file
     
    Is it possible and how can i do this ?
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    There are different ways to count the weeks.
     
    If you want to do this according to ISO 8601, it's a bit more complicated.
     
    E.g. 2024-12-31 is in week 1 of 2025 (but formatNumber(add(div(dayOfYear('2024-12-31'),7),1),'00') returns '53')
     
    To get the correct answer (according to ISO 8601), you can try this expression (assuming the date is in a Compose called 'Date'):
    if(less(div(add(10,sub(dayOfYear(outputs('Date')),if(less(dayOfWeek(outputs('Date')),1),7,dayOfWeek(outputs('Date'))))),7),1),if(or(and(equals(mod(sub(int(formatDateTime(outputs('Date'), 'yyyy')), 1),4),0),not(equals(mod(sub(int(formatDateTime(outputs('Date'), 'yyyy')), 1),100),0)),equals(dayOfWeek(concat(string(sub(int(formatDateTime(outputs('Date'), 'yyyy')),1)),'-01-01')),3)),and(not(equals(mod(sub(int(formatDateTime(outputs('Date'), 'yyyy')), 1),4),0)),equals(dayOfWeek(concat(string(sub(int(formatDateTime(outputs('Date'), 'yyyy')),1)),'-01-01')),2))),53,52),if(greater(div(add(10,sub(dayOfYear(outputs('Date')),if(less(dayOfWeek(outputs('Date')),1),7,dayOfWeek(outputs('Date'))))),7),if(or(and(equals(mod(int(formatDateTime(outputs('Date'), 'yyyy')),4),0),not(equals(mod(int(formatDateTime(outputs('Date'), 'yyyy')),100),0)),equals(dayOfWeek(concat(formatDateTime(outputs('Date'), 'yyyy'), '-01-01')),3)),and(not(equals(mod(int(formatDateTime(outputs('Date'), 'yyyy')),4),0)),equals(dayOfWeek(concat(formatDateTime(outputs('Date'), 'yyyy'), '-01-01')),2))),53,52)),1,div(add(10,sub(dayOfYear(outputs('Date')),if(less(dayOfWeek(outputs('Date')),1),7,dayOfWeek(outputs('Date'))))),7)))
    You can find further explanations here:
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    As @Chriddle pointed out this does not return an ISO week number. In fact, the expression below considers the start of the week a Saturday. If you want the start of the week to be Sunday so it at least aligns with the Excel =WEEKNUM([@Date]) function, you need to use this expression:
     
    formatNumber(add(div(sub(dayOfYear(outputs('Compose_Today')), dayOfWeek(outputs('Compose_Today'))), 7), 2), '00')
     
    Replace outputs('Compose_Today' with your date value. I created a flow to output this for one year and to confirm this expression aligns with the Excel formula.
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    Excel supports ISO 8601 week numbers:
    =WEEKNUM([@Date];25)
     and the first day of the week is Monday ;)
  • CF-19021403-0 Profile Picture
    18 on at
    Thanks @David and @Chriddle
     
    So can i write this ? ( i change "outputs('Compose_Today') by (utcNow() ")
     
    formatNumber(add(div(sub(dayOfYear(utcNow(), dayOfWeek(utcNow()), 7), 2), '00')
     
    Our weeks begins at Monday
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    Re: Excel supports ISO 8601 week numbers: =WEEKNUM([@Date];25)
     
    Except the function in Excel for ISO week numbers is =ISOWEEKNUM([@Date]) instead.
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    @CF-19021403-0
    It depends. There are differences in the definition of week number around the world.
    For the US this should be fine: formatNumber(add(div(sub(dayOfYear(utcNow()), dayOfWeek(utcNow())), 7), 2), '00')
    But in Europe my expression below is the right way.
     
    @David_MA
    WEEKNUM([@Date];25) and ISOWEEKNUM([@Date]) do the same (although ISOWEEKNUM([@Date]) seems preferable)
  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at
    @Chriddle there are definitely variations around the world on which day is the first day of the week. But there is a difference between the WEEKNUM and ISOWEEKNUM functions in Excel. WEEKNUM always considers the start of the year as January 1, while ISOWEEKNUM considers it to be the first week with a Thursday.
     
    I could not find a direct Excel reference from Microsoft, but I found this reference that explains this: WEEKNUM vs. ISOWEEKNUM: What's The Difference in Excel?. However, Microsoft does explain the difference here: WeekNum and ISOWeekNum functions - Power Platform | Microsoft Learn. The MS reference also shows how to set which day of the week you want to start the weeks on.
     
    The attached spreadsheet I generated using your ISO expression to generate the week number and then added columns with WEEKNUM and ISOWEEKNUM to highlight the differences.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard