cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HFG
Advocate II
Advocate II

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
mdevaney
Super User III
Super User III

@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
mdevaney
Super User III
Super User III

@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?

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.)
mdevaney
Super User III
Super User III

@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."

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? 

 

 

mdevaney
Super User III
Super User III

@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

Haha, yes, that's crazy! 

 

Thanks

mdevaney
Super User III
Super User III

@HFG 

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (29,243)