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 know whether us...
Power Automate
Answered

How to know whether user choose by month(s) or week(s) using power automate expressions.

(0) ShareShare
ReportReport
Posted on by 128

Hi PA users!

 

I've been working on it but can not find a solution yet..

 

Requirement-

The user can choose the start and end date from 2 date pickers in power apps,

user can either choose minimum from 1 week(ex. Thursday 30/09/2021- Wednesday 06/10/2021), 7 days per unit;

or user can choose per month (ex. 01/09/2021-30/09/2021, or 03/09/2021- 02/11/2021, ..) ,

the maximum duration is 4 months.

 

Now the case is-

I need to record the duration either 'by month(s)' OR 'by week(s)' into a excel column:

ex. if the user choose Thursday 30/09/2021- Wednesday 06/10/2021 , then the it should be recorded as '1' in the excel 'week' column. If the user choose 03/09/2021- 02/11/2021,  then the it should be recorded as '2' in the excel 'month' column.

 

I tried the solution by using DateDiff( ) function, count the user chosen duration by days, then divided by 7 in the power automate to record the duration only by week(s), but can not find a solution to distinguish whether the user choose by weeks or by month, mainly because there could be 28 days in Feb. and it can be 4 weeks as well if the user choose from the other months.

I don't want to add the control in PA, requesting user indicate whether they choose by month or by weeks. 

Searching for solution from power automate expressions...

Does any one have any advices?   

 

many thanks in advance!

PA user

Categories:
I have the same question (0)
  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @devsyw  so in by week select, user will select a specific week or different between start and end date can be more than a week?

  • devfv Profile Picture
    128 on at

    Hi @Anna ,

     

    thanks for your reply,

    I did not totally understand your question,

    the user can select minimum one week , maximum to 4 months.

    for example, user can select Thursday 30/09/2021- Wednesday 06/10/2021 as one week ( the start day can be any day of a week), or add 7 days each time, till 4 months (which is the maximum duration).

     

    user can also select 02/09/2021- 01/10/2021 as one month ( the start day can be any day of a month), or add one month per unit each time, till 4 months 🙂

     

     

  • VJR Profile Picture
    7,635 on at

    Hi @devsyw 

     

    At a time one can select the dates in both the dtPickers only once.

    So not sure how are you referring that "user can select 1 week or add 7 days each time, till 4 months"

     

    Is it not that - If the datediff is > 7 it should be considered as months and if <7 then week?

     

    Still trying to figure out the requirements 😊.

  • devfv Profile Picture
    128 on at

    Hi @VJR ,

    thanks for reply,

     

    the user can only choose 1 duration from 2 date pickers( one start date, one end date).

    minimum for  this '1' and only duration is 1 week(7 days), max is 4 months.🙂

     

     

  • VJR Profile Picture
    7,635 on at

    @devsyw so in that case what is your opinion about the below?

     If the datediff is > 7 it should be considered as months and if <7 then week

  • Verified answer
    devfv Profile Picture
    128 on at

    I found a way: if the days can be divided by 7,  then it can be considered as by weeks (but Feburay will be an exception), as for 91 days, I consider it's by months (that user normally has chosen 3 months instead of 13 weeks).

     

    It's still not a fully developed solution, any other suggestions are welcome, maybe need to pass it through the flow and see available actions to determine the real calendar that user-chosen?

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 375 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 269 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 127 Most Valuable Professional

Last 30 days Overall leaderboard