cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
HFG
Level: Powered On

Time Date format returned from Flow

Hi all,

 

I have an app that is connected to a SQL DB. OnSelect of a button I have a Flow that executes a stored procedure and returns the information to PowerApps. In the response part of the Flow there is a TimeDate2 (2) column from SQL being returned as a string in JSON, this gives the response in the following format: "YYYY-MM-DDTHH:MM:SS.ss". I have tried using "Text(ThisItem.TSP_MsgTime, DateTimeFormat.ShortDateTime)" in PowerApps to format the date, but it is still showing as in the Flow response. Any ideas how I can get it to format properly? I would like it in the format DD/MM/YYYY HH:MM:SS, without the T in the middle and the final milliseconds. 

 

Thank in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Time Date format returned from Flow

@HFG 

Yes, you can definitely convert into a datetime and then apply a TEXT function.

 

With(
    {FlowYear:Value(Left(Label1.Text,4)),
    FlowMonth:Value(Right(Left(Label1.Text,7),2)),
    FlowDay:Value(Right(Left(Label1.Text,10),2)),
    FlowHours:Value(Right(Left(Label1.Text,13),2)),
    FlowMin:Value(Right(Left(Label1.Text,16),2)),
    FlowSec:Value(Right(Left(Label1.Text,19),2))
    },
    Text(
DateAdd(
DateAdd(
DateAdd(
Date(FlowYear,FlowMonth,FlowDay),FlowHours,Hours),
FlowMin,Minutes),
FlowSec,Seconds),
"dd/mm/yyyy hh:mm:ss"
) )

 

Crazy, right?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Time Date format returned from Flow

@HFG 

Can you please provide a specific example of a date/time returned by flow for the forum members to test when trying the conversion?

HFG
Level: Powered On

Re: Time Date format returned from Flow

Hi @mdevaney

 

Here is an example: 

2019-10-28T15:14:54.15
I have also attached a screenshot of the JSON response. 
 
Thanks in advance for any help.
 
(In the meantime, I am going to try to remove the parts of the string I don't need using functions.)
Super User
Super User

Re: Time Date format returned from Flow

@HFG 

Here's my suggestion

 

With(
    {FlowDT:Label1.Text},
    Right(Left(FlowDT,10),2)&"/"&
    Right(Left(FlowDT,7),2)&"/"&
    Left(FlowDT,4)&" "&
    Right(Left(FlowDT,13),2)&":"&
    Right(Left(FlowDT,16),2)&":"&
    Right(Left(FlowDT,19),2)
)

 

It will convert this text

 

2019-10-28T15:14:54.15

 

Into this text

 

28/10/2019 15:14:54

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

HFG
Level: Powered On

Re: Time Date format returned from Flow

Hi, 

 

Thank you. 

 

So you think there is no way that PowerApps can recognise it as a datetime in order to make use of all the different formats available? 

 

 

Super User
Super User

Re: Time Date format returned from Flow

@HFG 

Yes, you can definitely convert into a datetime and then apply a TEXT function.

 

With(
    {FlowYear:Value(Left(Label1.Text,4)),
    FlowMonth:Value(Right(Left(Label1.Text,7),2)),
    FlowDay:Value(Right(Left(Label1.Text,10),2)),
    FlowHours:Value(Right(Left(Label1.Text,13),2)),
    FlowMin:Value(Right(Left(Label1.Text,16),2)),
    FlowSec:Value(Right(Left(Label1.Text,19),2))
    },
    Text(
DateAdd(
DateAdd(
DateAdd(
Date(FlowYear,FlowMonth,FlowDay),FlowHours,Hours),
FlowMin,Minutes),
FlowSec,Seconds),
"dd/mm/yyyy hh:mm:ss"
) )

 

Crazy, right?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

HFG
Level: Powered On

Re: Time Date format returned from Flow

Haha, yes, that's crazy! 

 

Thanks

Super User
Super User

Re: Time Date format returned from Flow

@HFG 

Awesome.  Make sure to close the thread if your issue is solved 😸

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,846)