MICROSOFT DYANMICS 365 to CALCULATE FULL MONTHS BETWEEN TWO DATES
Create New Account:
Click New >Give details >Name>mobile number>Address>Location> e.t.c.
Go To Settings>Advanced Settings>settings>open Solution
Create a new Entities>Name Account
Open Account> Create Fields
>Strat date of Month
>End Date of Month
>Difference Months
>Difference Days we need create fields
click on Save And close we need to save every what we done on Fields.
FORMS:-
Forms>Open Account> Field explorer we check their all fields what we Saved in the new fields.
We need to drag and drop Field in the account form.
We need to save & Publish .
Open Account and check what we create on fields in the form All will display on Account Form
In Account ribbon click in flow
create a flow>create a New flow>Instant cloud flow
Microsoft dataverse > when a row added, modified or deleted
Change type;-Added or modified
Table name:- Accounts
Scope:- Organization
Select columns:-cr0a1_stratdate,cr0a1_enddate
NOTE:-Every variable have a peek code
New Step:-
Compose Start of Month for Start Date – to get the start of the month for the start date we just use the startOfMonth function.
Compose End of Month for End Date – as there is no end Of Month function in Power Automate we have to get slightly more creative to calculate the end of month. For my expression I add one month to the End Date, then use the startOfMonth function to get the 1st day of that month, then subtract one day to get the end of month date
Compose DiffinDays – now that we have the proper Start Date and End Date we want to work with we need to calculate the total number of days between the dates. There is no datediff function in Power Automate, so we need to convert them to their ticks representation, then subtract the start date value from the end date value, then divide the result by 864000000000 and then add 1 to get the total number of days between the values.
Compose DiffinMonths – now that we have the total number of Days between the two dates we need to calculate the total number of months. In order to do that we divide the resulting value from above by 365.25/12. We use 365.25 to account for leap years, and divide 365.25 by 12 to get an average value for months.
Compose DiffinMonth Round – the final step is to round the value returned from the step above to the closest integer. In order to do this we need to add 0.5 to the value as the rounding calculation always rounds down. We then convert the float value to a string, split it on the decimal point, take the first part of the value (i.e. the integer) and convert that back to an integer value
Compose diffinmonths condensed
To make this flow more efficient we combine all of the steps above into a single Compose action with the full expression
Final step:-Update a Row
We need add all forms to dynamic content in row Update
For any Help or Queries Contact us on info@crmonce.com or +919014146800.