I've built a proof of concept which filters a table of data using office scripts and returns an image of the table of data that has been filtered. I am using the Today expression to apply a dynamic filter. My locale is UK GMT+1 and i noticed by accident that if I run the script from Power Automate prior to 8am, it will return yesterday's data but if I run it from Office Scripts, it will return today's. Therefore it looks like the Script is running UTC -7 via Power Automate but honours my locale from the Office Script when run from Excel.
Here is a basic office script demonstrating my problem, it's the definition of "ExcelScript.DynamicFilterCriteria.today" which is misbehaving for me. As well as the image, I return the Date() known by the script purely for debug:
function main(workbook: ExcelScript.Workbook) {
let table1 = workbook.getTable("Table1");
// Apply dynamic filter on table table1 column Date
let selected = table1.getColumnByName("Date").getFilter().applyDynamicFilter(ExcelScript.DynamicFilterCriteria.today);
let tableimage = table1.getRange().getImage();
return ([tableimage, Date()])
}
I have a table in the excel file as follows:
Date
| 08/06/2021 13:01 |
| 08/06/2021 14:01 |
| 08/06/2021 15:01 |
| 08/06/2021 16:01 |
| 08/06/2021 17:01 |
| 08/06/2021 18:01 |
| 08/06/2021 19:01 |
| 09/06/2021 13:01 |
| 09/06/2021 14:01 |
| 09/06/2021 15:01 |
| 09/06/2021 16:01 |
| 09/06/2021 17:01 |
| 09/06/2021 18:01 |
| 09/06/2021 19:01 |
When testing this out, I have run the flow before and after 8am GMT+1. You will see below that I have two different results, the first returning 8th June, the 2nd, 9th June i.e. today.

I have also output the utcnow() time from Power Automate and the Date() time from Excel Script which both match with GMT (remember that we are in GMT+1 due to summer).
If I check my timezone from Excel I am UK

Any ideas why I might be experiencing this? Has anyone else had timezone issues when running an office script in Excel vs from Power Automate?
If you want to watch my proof of concept that posts charts to teams / email using office scripts see here https://youtu.be/Tj2jasorczU
Thanks
Damien
P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉
@GeoffRen any ideas? Is it something obvious?