Number of months between two date fields | PowerAutomate

Bildschirmfoto 2020 11 03 um 15.39.14
Contents

    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)

    Updated on 1. April 2024
    Was this article helpful?

    Leave a Reply

    Your email address will not be published. Required fields are marked *