How to Find Next Month and Previous Month using Microsoft Flow within Dynamics 365 CRM

Sending
User Review
0 (0 votes)

Introduction

In this blog, we are checking how we can calculate the next/previous month’s date time from today’s date time or calculate the next/previous month’s date time from the selected date.

There is no direct way or predefined function to calculate the next/previous month in Microsoft Flow. However, we can achieve this process using the Add to time action. Following input parameters we need to provide Add to time action:

1. Base Time – It is the Date-Time value from where we add next month.
2. Interval –It is a numerical value that specifies how many months we want in Base Time.
3. Time Unit – It is a list of Time Units (Month, Week, Day, Hour, Minutes, and Seconds) which specify on which Time Unit we want to add Interval.

To understand more about the above parameters, let’s try this scenario in Dynamic 365 CRM.

Step 1:We create one Microsoft Flow and set that Flow Trigger on creating an Account entity record.

Find next month and previous month using Microsoft flow

Step 2: Add “Add to time” action with the following values

Find next month and previous month using Microsoft flow

In Base Time, we set today’s date, which means from today we are trying to get next month’s date.

In the Interval field, we set 1, which exactly indicates how many months that we need to add in the current date-time. So 1means we are trying to add one month from today’s date. If we want to find the previous Month’s date from today then you need to mention -1 in the interval field.

The last field is Time Unit, here we set Time Unit as “Month” because we need to find out the next month date from today’s date.

Step 3: From Step 2 we get the next month’s date which is in UTC format, so we need to convert this UTC date into Central Time date-time using the “Convert Time Zone” action.

Find next month and previous month using Microsoft flow

Base Time is a Date Time value that we get from Step 3 that we want to convert into Central Time Zone.

Format String indicates on which date-time format we want this date.
Source Time Zone indicates the Time Zone of Date Time value that we want to convert.
Destination Time Zone indicates the output Time Zone

Step 4: Update the calculated output value in the Dynamics CRM field.

For Next Month:

Find next month and previous month using Microsoft flow

For Previous Month:

Find next month and previous month using Microsoft flow

Conclusion

We achieved and understood the process for how to calculate next / previous ‘X’ months, weeks, days, hours, minutes, and seconds in Microsoft Flow.

attach2dynamics