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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Why is my expression g...
Power Automate
Answered

Why is my expression giving me yesterday's date?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

Friday and today this expression is returning yesterday's date instead of today's: 


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


My computer date and time are correct. Do I have something entered incorrectly?

Thanks,
Beth

 

 

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Anonymous 

    the utcNow() expression returns the current date and time in UTC - you have a time zone issue.

    You can use the Convert time zone action or the convertTimeZone() expression to convert to your local time zone.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, Scott, for the quick reply.  

    I'll try converting the timezone. 

    So weird, though. . . it worked fine then it didn't. 

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Anonymous 

    I suspect that the reason that it seemed like it worked and then it didn't might be that it depends on the time of day that you ran the Flow.  Sometimes the date is the same where you are and in UTC time and sometimes it isn't.....

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I used convertTimeZone and it did the same thing. It puts in yesterday's date in the record.

     

    This is the expression I used:  convertTimeZone(utcnow(),'UTC','Eastern Standard Time','yyyy-MM-dd')

     

    I'm writing the records that are updated to an Excel file.  The date that's being written to the file using that expression is correct (today's date).  But the date written to Dynamics is yesterday's. The update action in the flow is using the same convertTimeZone() expression. 

     

     

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    Hi @Anonymous ,

     

    Could you please provide the screenshot of the Flow configuration to do a further analysis?

    You could use check the date of utcNow() in Convert Time zone action and see if it is an expected date.

    Image reference:

    12.PNG

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-bacao-msft ,

     

    The convert time zone expression in the input/output for the Add Row and Update Record actions returns the correct date.

    Same thing happens with the convert time zone action.

     

    The records written to the Excel worksheet have the correct date.  In the Dynamics sandbox the date in the records gets updated to the previous day's date.

     

    My clock is correct, my timezone is set correctly in user settings. The field updated in the sandbox is a Date Time field set to date only. There are no business rules applied to the field. There is no reason that I can see for the date to change when it's written to the Dynamics record. What else should I check?

     

  • v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    Hi @Anonymous ,

     

    Could you please share the flow configuration so that we could reproduce the flow and check the cause of the issue?

    Besides, you could set Destination time zone the same as time zone of Dynamics.

    And you could check the source date in flow run history to see if it is the expected date.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry for the slow response.

     

    The flow is running against Leads after a field is updated.  The record that has been updated is added to an Excel file and then a date field is updated on the record.  A 15 second delay at the end allows time for the row to be added to Excel and Dynamics to be updated. 

     

    The expression for the Date Added to Air Support field is:  convertTimeZone(utcnow(),'UTC','Eastern Standard Time','yyyy-MM-dd')

     

    From a flow run yesterday (4/23/20):

    Add a Row

    Lead_Add a Row_042420.png

     

    Update a record:

    Lead_Updae a Record_042420.png

     

    Add a row input and output:

    Lead_Input_Add a Row_042420.pngLead_Output_Add a Row_042420.png

     

    Update a record input and output:

    Lead_Input_UpdateaRecord_042420.pngLead_Output_UpdateaRecord_042420.png

     

    Excel file Date Added to Air Support field:

    Lead_Excel_Added Row_042420.png

     

    Dynamics Date Added to Air Support field:

    Lead_Dynamics_UpdatedRecord_042420.png

  • Verified answer
    v-bacao-msft Profile Picture
    Microsoft Employee on at

     

    Hi @Anonymous ,

     

    Thank for your reply!

    It is strange, it seems that the performance of Flow is correct, the date needs to be added in Body is correct.

    Have you refreshed the webpage to check if the date is still not the expected one?

    If this date does not contain the time, maybe use addDays() function to add a day when you configuring Update record action is a workaround. I am afraid that I am not able to find the cause of this issue on my side currently.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for looking into it, @v-bacao-msft.

     

    I think I'll leave it alone. Maybe it will correct itself eventually.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 997

#2
Valantis Profile Picture

Valantis 810

#3
Haque Profile Picture

Haque 642

Last 30 days Overall leaderboard