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 / Compare date to determ...
Power Automate
Unanswered

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!

Categories:
I have the same question (0)
  • Verified answer
    ccc333ab Profile Picture
    1,144 on at

    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
  • kamotekid Profile Picture
    25 on at

    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?

     

  • ccc333ab Profile Picture
    1,144 on at

    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

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

    Many thanks!

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