web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Format Date Compose ad...
Power Automate
Unanswered

Format Date Compose adding to date

(0) ShareShare
ReportReport
Posted on by 71

Hi,

 

I have built a flow to go off when a sharepoint item is modified.

 

In the flow, I would like to subtract one date from another to get a number of days.

 

To do this, I have put the modified date and report date into compose actions and set the expressions as formatdatetime((composeitem),'dd/MM/yyyy').

 

When I test it, for some reason it spits out the date with months added in.

 

jessicabishop47_0-1673496741035.png

 

Does anyone know how I can fix this?

Categories:
I have the same question (0)
  • grantjenkins Profile Picture
    11,063 Moderator on at
    Re: Format Date Compose adding to date

    To find the days between two dates you would get the number of ticks for each date, subtract one from the other, then divide by 864000000000. See example below that subtracts the Modified date from the current date to find out the days between. You would just need to replace utcNow() with your Report date.

     

    div(sub(ticks(utcNow()), ticks(triggerOutputs()?['body/Modified'])), 864000000000)

     

    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • jessicabishop47 Profile Picture
    71 on at
    Re: Format Date Compose adding to date

    Hi @grantjenkins 

     

    Thanks for that. My main concern was for the months being added to the formatted date. Can you help with that?

  • grantjenkins Profile Picture
    11,063 Moderator on at
    Re: Format Date Compose adding to date

    Can you show your exact formula you've used to format the date? You should have something like:

     

    formatDateTime(outputs('modified'), 'dd/MM/yyyy')
  • Verified answer
    jessicabishop47 Profile Picture
    71 on at
    Re: Format Date Compose adding to date

    This is the formula used:

     

    formatDateTime(outputs('modified'),'dd/mm/yyyy')
  • jessicabishop47 Profile Picture
    71 on at
    Re: Format Date Compose adding to date

    I think I've just found that it was taking the minutes value from the datetime.

     

    Is that formula correct?

  • grantjenkins Profile Picture
    11,063 Moderator on at
    Re: Format Date Compose adding to date

    Lowercase m refers to minutes, while uppercase M refers to month. You should have 'dd/MM/yyyy'.

     

    If you look at the modified date, the minutes are 09 which is what's coming up as your months since you used lower case m.

  • jessicabishop47 Profile Picture
    71 on at
    Re: Format Date Compose adding to date

    I just saw that, thank you. I think I got confused because I had seen that before, and changed it but I must not have saved it 🥴. Thanks for your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard