cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Date range count weekdays

Hello,

 

I´m getting following value through a OData call:

"startDate": "2020-08-13T00:00:00",
"endDate": "2020-06-19T00:00:00",
"quantityInDays": "252.0"

 I´m parsing the value and have the values ready.

 

I want to achieve the amount of days from the month July as a example. To count the Weekdays I can use DayOfWeek().

I´m sure I need the startOfMonth() and the last the of the month July, I also know how to resolve that.

 

But how can I check if the datespan above is valid in the month July or current month as a example? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Date range count weekdays

Hello @Belasor 

  • Check if July is in the timespan:

month.png

 

Using the expression:

int(formatDateTime(triggerBody()?['date'],'MM'))

We get the month of a date, and convert it to an integer value.

 

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

7 REPLIES 7
Highlighted
Super User II
Super User II

Re: Date range count weekdays

Hello @Belasor 

Could you describe in a more detailed way which is your question? What do you mean by saying "But how can I check if the datespan above is valid in the month July or current month as a example?"

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted
Helper III
Helper III

Re: Date range count weekdays

Sorry, I just want to calculate the days which are currently in July as a example within the date span.

"startDate": "2020-08-13T00:00:00",
"endDate": "2020-06-19T00:00:00",
"quantityInDays": "52.0"(Example Value)

 So I can get the quantityInDays for July. Because the quantitiyInDays is showing me all days during the timespan but I just want them for July as a example.

Highlighted
Super User II
Super User II

Re: Date range count weekdays

Hello @Belasor 

My suggestion is that you use work with the date and time functions available here , since I don't really understand your question (do you want to see how many months are in the time span, for example?).

Let's see if other peers can help you whit this.

Regards,

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted
Helper III
Helper III

Re: Date range count weekdays

I just want to check if the month July is within the timespan, if yes, count how many working days are in the month July. 

 

Thank you for the help 🙂

Highlighted
Super User II
Super User II

Re: Date range count weekdays

Hello @Belasor 

  • Check if July is in the timespan:

month.png

 

Using the expression:

int(formatDateTime(triggerBody()?['date'],'MM'))

We get the month of a date, and convert it to an integer value.

 

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Highlighted
Helper III
Helper III

Re: Date range count weekdays

Thank you for the help.

 

Just one small question.

I´m formatting the output with following expression

int(formatDateTime(outputs('Compose_startDate_to_time_format'),'MMyyyy'))

Unfortunatelly it´s removing the 0 at the beginning of the month January as a example. In this case the number is always smaller. I could fix this with the "string" expression but it wouldn´t be possible anymore to use the "less than" or "greater than" operator. 

compose.png

 

If there is no easy solution, the only option would be to change the year and the month in the order right :)?

Highlighted
Super User II
Super User II

Re: Date range count weekdays

Hello @Belasor 

I don't understand your problem.

If you need to compare with a number, then you use the "int" function, but if you need the string value of the month, then you can use the same expression without converting it to integer.

In any case, if you want to compare dates, you can use the ticks function. It is the best option to compare dates: https://sharepains.com/2018/11/02/microsoft-flow-compare-dates-using-conditions-in-the-sharepoint-co...

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (7,847)