There are several options in Microsoft Flow to start manipulating a date. You have the functions adddays(), addmonths(),… and then also the actions Add Time and so on. However, these don’t always give you the desired result. So here’s a quick fix to get your desired date.
We’re going to divide the date in the flow first into day, month and year. After that, we will edit these components separately and in the last step, we will merge them into the new date.
Step 1 – Initialize the date
Enter your date in the ‘Value’ place. The advantage of using a variable is that you only need to initialize it once. After that, you can use the same name for each step. The date can come from any data source: SQL, CDS, SharePoint,…
Step 2 – Modify the date parts
As you can see we do 3 operations on the date. One of each segment of the date. If you only want to change the month or the year this is also possible. Then you only need to use the Flow block that applies to you.
Formula Yearadd(int(formatDateTime( variables(‘date’) ,’yyyy’)), number_to_change)
Formula Monthadd(int(formatDateTime( variables(‘date’) ,’MM’)), number_to_change )
Formula Dayadd(int(formatDateTime( variables(‘date’) ,’dd’)), number_to_change )
The number_to_change is the parameter you need to change in the formula. this will take care of the number of days, weeks or years that will be added to or subtracted from the date.
Step 3 – Recombine the date parts
In the penultimate step, we are going to overwrite the variable date. this is done by means of the action ‘Set Variable’. The outputs are the outputs of the previous 3 compose steps.
At the latest, we are going to convert the date to a UTC Format. In this example, it is set up according to the European standards but you can change this to your own interest.
Formula ComposeconvertToUtc(variables(‘date’),’W. Europe Standard Time’,’dd/MM/yyyy HH:mm’)
So this was my first quick tip for Flow. Hopefully you will be able to apply it as well. See you next time!