I have flow that gets a data from dataverse and puts in into a CSV table to be sent as attachment in email and for saving in One Drive. The issue is I'm changing the DateFormat of one of the columns into the CSV table but after running the flow some of the records are properly formatted into what I put in the expression and some have different formats applied to them.
Here's how I used the CSV Table
And this is how it looks like when the file is generated in one drive and the file attached to the email.
Hi Emad,
I've created this file also via flow with .csv extension file name using CREATE FILE action from One Drive business. I'll try changing it to xlsx extension to see how it goes. But I need that feature in PowerApps where they can export with csv or xlsx option so if it's messing up in CSV that will cause an issue on my side.
Hi @RazenC ,
I think this is excel file, if it is an excel file please fix the format from the excel template itself not the power automate flow.
If this post helps you with your problem, please mark this answer as Accepted Solution.
If you like my response, please give it a Thumbs Up.
Sorry. Got lost on this one. I still get the part about switching the MM and mm but do you mean the problem is in the records itself based on how it is formatted?
I tried removing the HH:mm:ss in the date format with these remaining
formatDateTime(item()?['cr21b_requirementcreatedate'], 'yyyy-MM-dd')
but still the results is giving me these formats
I'm really lost.
The first example you showed from the initial post had the Minutes in the Months place.
MM=months
mm=minutes
Your first example:
formatDateTime(item()?['cr21b_requirementcreatedate'], 'yyyy-mm-dd HH:MMss')
Notice the MM and mm are switched around.
When this ran through power automate and the CSV - it recognized this as text for most of the datetimes since none of them were actual date times (example 2020-55-21 is not a date). However, some of them did make an actual date time, so the CSV converted it into date format.
Hi, Thanks for looking into this. But unfortunately it doesn't solve the issue.
After applying the format you've suggested
formatDateTime(item()?['cr21b_requirementcreatedate'], 'yyyy-MM-dd HH:mm:ss')
There are no records that are not updated or have different format but the results became this.
Just for additional info. I tried removing the date format and it looks like this.
This is how it looks like in Dataverse.
Actually I'm also putting this in a HTML table to be sent in an email. But it doesn't cause any issues
Really confused why this works and not in CSV table.
Hi, @RazenC
According to your screenshot , you are using the formatDateTime() function to get the format of the date.\
You can try to use the 'yyyy-MM-dd HH:mm:ss' to test .
For more information, you can refer to :
Custom date and time format strings - .NET | Microsoft Learn
I test it in my side , it works good where the column in my dataverse columnn type is "DateTime":
The result is as follows:
Second, you can check that the date format you have the problem with is the same as the date format returned correctly. You can check this in the output in above action.
You can compare the difference between the correct and incorrect values in the results returned in the previous step.
If this still doesn't help you solve the problem, you can provide me with some format data in Dataverse that has problems, along with your expected output, so that I can better help you.
Best Regards,
Yueyun Zhang