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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Formatdatetime with ut...
Power Automate
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')?

Categories:
I have the same question (0)
  • Verified answer
    tom_riha Profile Picture
    10,185 Most Valuable Professional on at

    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

    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,185 Most Valuable Professional on at

    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

    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

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

     

  • visalpucca Profile Picture
    6 on at

    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

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard