logo
search
Others

Fix Power Automate Excel Script Using the Wrong Date and Time

Emma BrownEmma Brown Oct 23, 2026 868 views

Question details

The user's Power Automate flow triggers an Office Script in an Excel file on OneDrive, but the script outputs an incorrect or unexpected date and time.

Fix Power Automate Excel Script Using the Wrong Date and Time
Product
Microsoft Excel, Power Automate
Device & OS
not provided
Scenario
Running an automated workflow where a Power Automate flow executes a custom Office Script on a cloud-hosted Excel spreadsheet.
Observed behavior
The generated date and time do not match the user's local timezone, typically defaulting to UTC because of cloud server processing.
Before you start

Verify your local time zone requirements and check if your Power Automate flow is currently handling date and time values in Coordinated Universal Time (UTC).

Solution 1Recommended

Use the Convert Time Zone Action in Power Automate

Format and convert the UTC time to your local time zone directly within Power Automate before passing it to the Excel script.

Power Automate and OneDrive servers operate in UTC by default. To prevent the Office Script from logging the wrong time, you should handle the time conversion inside the flow.

1
Add a new action

Open your flow in Power Automate, click the '+' icon before your 'Run script' step, and search for 'Convert time zone'.

2
Configure the time zone settings

Set the 'Base time' to 'utcNow()'. Set the 'Source time zone' to '(UTC) Coordinated Universal Time' and the 'Destination time zone' to your local time zone.

3
Format the time string

Choose a 'Format string' that matches how you want the date to appear in Excel (e.g., 'yyyy-MM-ddTHH:mm:ss').

4
Pass the parameter to your script

Update your 'Run script' action to accept this converted time output as an input parameter for your Excel Office Script, rather than letting the script generate the time.

Use the Convert Time Zone Action in Power Automate
Best Practice: Passing dates as formatted strings from Power Automate to Excel prevents unexpected shifts caused by Excel's internal date serial numbers.
Free Microsoft Office alternative

Need a Simpler Way to Manage Spreadsheets? Try WPS Office

If troubleshooting complex cloud workflows, Power Automate scripts, and timezone errors is slowing you down, WPS Office provides a lightweight, highly compatible, and user-friendly alternative for your spreadsheet needs.

  1. 1. Download and Install: Get WPS Office for free from the official website and install it on your device.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheets and seamlessly open your existing Microsoft Excel files.
  3. 3. Use Built-in Functions: Easily manage local dates and times using intuitive formulas like =TODAY() and =NOW() without complex scripting.
Seamless compatibility with Microsoft Excel (.xlsx, .xls) formats.Reliable built-in date and time functions that sync perfectly with your local system.Lightweight installation that runs smoothly on Windows, Mac, Linux, and mobile devices.Familiar user interface allowing you to work efficiently with zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Power Automate always default to UTC for dates?

Power Automate is a global cloud service. Standardizing all date and time values to Coordinated Universal Time (UTC) prevents data conflicts and synchronization errors across different servers, regions, and integrated applications.

Can I format the date directly inside the Excel Office Script instead?

Yes, you can use TypeScript methods like `toLocaleString()` inside your Office Script to adjust the timezone. However, handling the conversion in Power Automate is generally recommended as it is more visually configurable and easier to maintain.

Does the OneDrive server location affect my Excel script's time?

Yes, cloud-hosted files run on regional servers. If a script requests the current system time without specifying a timezone, it will pull the time from the server's location or default to UTC, which often differs from your local PC time.