cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

@formatDateTime

Hello,

I have problem with @formatDateTime forumala in compose action. I need to format date  to supported flow format.

 

I tried these variants:

"@formatDateTime(‘custom_date_column’, 'o')"

"@formatDateTime(‘custom_date_column’)"

"@formatDateTime(concat(formatDateTime(‘custom_date_column’​​,'yyyy-MM-ddThh:mm:ss'),'-3:00'),'d/MM/yyyy hh:mm tt')"

"@formatDateTime(‘custom_date_column’,'yyyy-MM-dd hh:mm:ss')"

 

And in all variants, I receive error

 'In function 'formatDateTime', the value provided for date time string (‘custom_date_column’ was not valid. The datetime string must match ISO 8601 format.'.

 

Maybe someone have ideas how to format date column from SharePoint Online list?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: @formatDateTime

Hi @Mumbrasas,

 

Simply input the column name with the FormatDateTime function from SharePoint online list would not work here.

As the function is used under Microsoft Flow, we should use the Triggers/Actions and the related part from the them to identify the corresponding columns.

For example, here we take use of the When a New Item is created as the Flow trigger, then we need to use the EndTime value from the SharePoint list, we should write the formula under Compose Action as below:

"@formatdatetime(triggerBody()?['EndTime'],'yyyy-MM-ddThh:mm:ss')"

Mostly this is not so easy for end users to handle, so I would share a little tricks to find the content part:

1. Add a Compose Action after the trigger/Action, then specify the Compose input with the following format:

"@formatdatetime( ,'yyyy-MM-ddThh:mm:ss')"

2. Click at the first parameter part of the formatdatetime, then choose the corresponding dynamic content, save it,

3. Microsoft Flow won't save successfully, and would notify the error message of validation failed,which then we may find the corresponding part for the input,

4. Copy and paste the corresponding data within the braces @{ } into the function first parameter, then save the flow

Adding screenshots as reference:

68.PNG

69.PNG

70.PNG

Hope this helps,

Regards

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

15 REPLIES 15
Highlighted
Community Support
Community Support

Re: @formatDateTime

Hi @Mumbrasas,

 

Simply input the column name with the FormatDateTime function from SharePoint online list would not work here.

As the function is used under Microsoft Flow, we should use the Triggers/Actions and the related part from the them to identify the corresponding columns.

For example, here we take use of the When a New Item is created as the Flow trigger, then we need to use the EndTime value from the SharePoint list, we should write the formula under Compose Action as below:

"@formatdatetime(triggerBody()?['EndTime'],'yyyy-MM-ddThh:mm:ss')"

Mostly this is not so easy for end users to handle, so I would share a little tricks to find the content part:

1. Add a Compose Action after the trigger/Action, then specify the Compose input with the following format:

"@formatdatetime( ,'yyyy-MM-ddThh:mm:ss')"

2. Click at the first parameter part of the formatdatetime, then choose the corresponding dynamic content, save it,

3. Microsoft Flow won't save successfully, and would notify the error message of validation failed,which then we may find the corresponding part for the input,

4. Copy and paste the corresponding data within the braces @{ } into the function first parameter, then save the flow

Adding screenshots as reference:

68.PNG

69.PNG

70.PNG

Hope this helps,

Regards

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: @formatDateTime

It's working. Thank you verry much.

Highlighted
Helper II
Helper II

Re: @formatDateTime

This works for me, however I am only able to use it once. 

 

I have a start and end date on my list, where I add 2 separate "Compose" actions, it ignores the second one. 

 

How can I have both working ?

Highlighted
Frequent Visitor

Re: @formatDateTime

Not sure if this is your issue, but i renamed my Compose titles to be 'First Day' and 'Last Day' and they then both showed up as individual outputs for selection.

 

Untitled.png 

Highlighted
New Member

Re: @formatDateTime

I cannot get this to work in my flow, i am trying to convert a US date format into an Australian date format with no success using the above fix. Any advice would be greatly appreciated.

 

Keeps emailing me like this, the bold part is my column name in my SharePoint list.

 

Start date: @{formatdatetime(@{triggerBody()?['Leave_x0020_start_x0020_date']},'dd/MM/yyyy')}

Highlighted
Frequent Visitor

Re: @formatDateTime

As per the instructions above, i think your problem is you need to remove the @{} symbols.  I think you'll find you need your function to look something like this.

 

"@formatdatetime(triggerBody()?['Leave_x0020_start_x0020_date'],'dd/MM/yyyy')"

 

I actually ended up using @addhours so that i could manipulate for DLS.   My code is below

 

"@addHours(triggerBody()?['Start_x0020_Date'],11,'dd/MM/yyyy-HH:mm')"

 

Highlighted
New Member

Re: @formatDateTime

Is there a trigger to make all outputs in formatdatetime in EST? 

Highlighted
New Member

Re: @formatDateTime

Thanks ill give that a try and let you know the outcome.

Highlighted
Advocate III
Advocate III

Re: @formatDateTime

My Condition 

if(greater(length(actionOutputs('DueDate')),0),formatDateTime(outputs('DueDate'),'yyyy-MM-dd'),''), works perfectly for valid date value, but for empty value it is no working.
The condition above mentioned getting fail if the value is empty 
 
if(equals(empty(actionOutputs('DueDate')),false),formatDateTime(outputs('DueDate'),'yyyy-MM-dd'),''), is also generating the error :
In function 'formatdatetime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'.
which hould not be the case for False condition.
Please suggect the solution.I am applying substring method to get the date.
Highlighted
Advocate III
Advocate III

Re: @formatDateTime

My Condition 

if(greater(length(actionOutputs('DueDate')),0),formatDateTime(outputs('DueDate'),'yyyy-MM-dd'),''), works perfectly for valid date value, but for empty value it is no working.
The condition above mentioned getting fail if the value is empty 
 
if(equals(empty(actionOutputs('DueDate')),false),formatDateTime(outputs('DueDate'),'yyyy-MM-dd'),''), is also generating the error :
In function 'formatdatetime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'.
which should not be the case for False condition.
Please suggect the solution.I am applying substring method to get the date.
Need to pass the null / empty string value to the date.
Highlighted
Regular Visitor

Re: @formatDateTime

Gunjan,

I've successfully used the @empty function to only call the @formatDateTime function when the string is not a null.  This may work better than your length-based approach. 

@if(empty(item()['startDateTime']), item()['startDateTime'], formatDateTime(item()['startDateTime'], 'MM/dd/yyyy'))

 

If the item is empty, then it just passes through the empty item.  If the item has a string, then it formats the string. 

 

Yours would be closer to

@if(empty(actionOutputs('DueDate')), actionOutputs('DueDate'), formatDateTime(actionOutputs('DueDate'),'yyyy-MM-dd'))

 

Hope this helps

-TMR

Highlighted
Advocate III
Advocate III

Re: @formatDateTime

Thank You for your respose , i found this as good solution to the problem...

Highlighted
Anonymous
Not applicable

Re: @formatDateTime

Hello,

 

Have any way to format output of compose2, for "yyyy-MM-dd" only? In my condition, when i compare this outputs of my composes, that value will be different. Can u help me to solve this problem? 

 

Thx,

Highlighted
Power Participant
Power Participant

Re: @formatDateTime

Hey @Anonymous 

 

 

Could you please share a screenshot of your Flow and some additional information about this problem you have.

 

Kind regards

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





Highlighted
New Member

Re: @formatDateTime

Hello,
I have similar issue with the date format in the condition section. I am trying to create a flow which will send an email to the team when the birthdate in the SharePoint list matches todays date. I am using the template from the menu,but the error prevails. I have tried all combinations without desired results.
Appreciate your assistance.
Thank you.

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (12,418)