Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Compare date to determine week number of an event

(0) ShareShare
ReportReport
Posted on by 25

Hi!

Here's a snapshot of the table I'm working on.  I am filtering rows whose start and end dates are current, based on utcNow(), and this flow will run as a weekly report.

kamotekid_0-1624135748331.png

 

In addition, I have a sharepoint list that contains Fiscal calendar details, like WeekOfYear, DayofYear, etc. 

Should I use that to determine what week the 'Title' is in based on the 'Proposed Start Date'?  For example, I want to use flow to output based on today's date, that we are on week '3' of the 'Siig Inc' row because its 'Proposed Start Date' is '07 Jun 2021'. I guess that mean using utcNow() to count number of weeks from 'Proposed Start Date'.

 

The values will be collected into an email body, arranged first by the Select action adn will look like:

'TITLE'  'Proposed Start Date'  'Proposed End Date'  'Event Week Number'

 

I was hoping for an easier way without having to reference the Fiscal calendar SP list, like a formula I can plug into an 'Apply to each' loop.

Thanks!

  • kamotekid Profile Picture
    25 on at
    Re: Compare date to determine week number of an event

    @ccc333ab - I just tried it now, and it works flawlessly!

    Many thanks!

  • ccc333ab Profile Picture
    1,144 on at
    Re: Compare date to determine week number of an event

    No, you shouldn't have to just as long as the date is in a date format (not a string). 

  • kamotekid Profile Picture
    25 on at
    Re: Compare date to determine week number of an event

    Thanks @ccc333ab 
    Ok, I'll try this out today.  If I already have the excel string 'Proposed Start Date' formatted to MM-dd-yyyy from a previous flow, should I still convert it to yyyy-MM-dd first?

     

  • Verified answer
    ccc333ab Profile Picture
    1,144 on at
    Re: Compare date to determine week number of an event

    Can you just use a mathematical formula to calcualte it out? Assuming start date is always Monday...you can: 

    • Days difference between Today's Date and Start Date 
    • Then divide that by 7 to see number of weeks (but just the quotient)
    • Then add 1 since the first week will give a zero, but you'll say that is in the first week

    So in Power Automate, I'd use this formula: 

    add(div(div(sub(ticks(utcnow()),ticks(formatDateTime(variables('strDate'),'yyyy-MM-dd'))),864000000000),7),1)

    Just replace variables('strDate') with whatever your start date is. Explaning this a bit but I can explain it moreif you want:  

    • Need to format the date coming out of excel as you'll be getting a string date (thus the formatDateTime expression)
    • the div/sub/ticks/840000000000 stuff is how you go about and calculate out the difference of dates in days
    • div will divide this by 7 (and only returns the quotient)
    • add will add the extra day

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1