Number of months between two date fields | PowerAutomate

Unfortunately, there is no Datediff function in PowerAutomate, so here is our solution to calculate the number of months between two dates.

Our data:

Date 1 = Current date, here we use the current date
Date 2 = A date field from SharePoint with the name Contract start

Jahresunterschied herausfinden

Mit folgender Formel finden wir den Jahresunterschied heraus:
sub(int(formatDateTime(body('Aktuelle_Zeit'), 'yyyy')), int(formatDateTime(outputs('Projektinfos_abrufen')?['body/Vertragsbeginn'], 'yyyy')))

Calculate delta of months

sub(int(formatDateTime(body('Aktuelle_Zeit'), 'MM')), int(formatDateTime(outputs('Projektinfos_abrufen')?['body/Vertragsbeginn'], 'MM')))

Combining the year difference and the months

add(mul(outputs('Delta_der_Jahre'), 12), outputs('Delta_der_Monate'))

Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

Was this article helpful?

Related Articles

Leave A Comment?