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 Automate - Building Flows
Answered

Formatdatetime with utcnow not getting the right date when running on a schedule flow

(1) ShareShare
ReportReport
Posted on by 15

Hello,

 

I have a flow running weekly at a specific time. 

At that time, the flow will go and grab and file and copy it to a different location.

That file is named with a date on which the flow runs.

The flow seems to run the next day, so it cannot find the file since the date/name of the file is different.

 

YaelD_0-1613668441070.png

 

It ran on the February 17 but looked for a while name that was the 02-18-2021. The file "Huddle 02-17-2021.docx" does exist, but not the one with the wrong date.

I'm getting this error:

YaelD_1-1613668618610.png

 

 

It used to work when that task was schedule to run at 3pm that day, but I need to run it later on.

Is there anything I need to add in that expression: formatDateTime (utcNow(),'MM-dd-yyyy')?

I have the same question (0)
  • Verified answer
    tom_riha Profile Picture
    10,179 Most Valuable Professional on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    Hello @YaelD ,

    utcNow() gives you the current date in the UTC time zone. If you run a flow at 19:00 in UTC-7 then the utcNow() will give you the next day at 2:00.

    You can add the 'Convert time zone' action, use the utcNow() as the input and convert it into UTC-7. Then you can use the output of that action for the file name, it should be the correct date.

    image.png

     

  • Verified answer
    YaelD Profile Picture
    15 on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    Thank you, I'll give that a try.

    In the meantime, I found something that could work:

    instead of

    formatDateTime (utcNow(),'MM-dd-yyyy')

    I put this

    formatDateTime (addHours(utcNow(), -7),'MM-dd-yyyy')

     

    If it doesn't do the trick, I'll try yours.

  • tom_riha Profile Picture
    10,179 Most Valuable Professional on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    That will work also fine, it'll achieve the same result: take the date/time in UTC and move it 7 hours back. 🙂

  • Mahipundir Profile Picture
    68 on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    thanks for the answer, 

     

    Is there any way I can add 2or3 days, data given by MS form or by manual tigger.? currently I'm using this expression which only adds days to current date. 

    formatDateTime(addDays(utcNow(),2),'dd-MMMM-yyyy')

    Thank you so much in advanced.
     
  • Herbertt Profile Picture
    65 on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    Hi - Should the convert time zone action come before or after the reoccurrence action??

     

  • visalpucca Profile Picture
    6 on at
    Re: Formatdatetime with utcnow not getting the right date when running on a schedule flow

    this medthod is working for me cheer

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 691 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 431 Moderator

#3
developerAJ Profile Picture

developerAJ 266

Last 30 days Overall leaderboard