cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
datedlime
Regular Visitor

formateDateTime - missing colon in time?

I'm using this expression:

 

formatDateTime(triggerOutputs()?['body/receivedDateTime'], 'yyyy-MM-dd hh:mm tt')

 

Output:

datedlime_0-1620323153248.png

Why is the colon not appearing in the time?

1 ACCEPTED SOLUTION

Accepted Solutions
eliotcole
Responsive Resident
Responsive Resident

Ah.

 

You are trying to make a file, correct? And you're using the date as the filename.

 

You can't have a colon in a filename, the flow is correcting this for you.

 

---

 

I have used a simple "replace()" function a few times in this expression to make a filename that you could easily organise:

replace(replace(replace(formatDateTime(triggerOutputs()?['body/receivedDateTime'], 'g'), '/', '-'), ':', '-'), ' ', '--')

 

What follows is an example of how I would recommend you export your email.

 

What I would suggest is that you create the exact same flow as this, separately to the flow that you're having issues with, so that you understand how it is put together.

 

Once you have that, you can then use it with whatever logic you already have:

email export flowemail export flow

 

Like I say ... You can wrap any other logic you have around this, just use it as an example:

View solution in original post

7 REPLIES 7
eliotcole
Responsive Resident
Responsive Resident

Hi, @datedlime , you can use this to immediately get the format that you want:

 

formatDateTime(triggerOutputs()?['body/receivedDateTime'], 'g')

 

 

----

 

I was going to the Microsoft Function/Expressions Reference Guide (bookmark that link! 🙂) to see what might be off with flow or your formatting, and when I got to the formatDateTime() section, I read:

Either a single format specifier or a custom format pattern. The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss.fffffffK), which complies with ISO 8601 and preserves time zone information.

 

So I followed the single format specifier link, and there are a ton of default types, of which yours is "g". So I just tested it with:

 

 

formatDateTime(utcNow(), 'g')

 

 

All good!

'g' does not give me the format I need, or the colon. This is what results:

datedlime_0-1620329267106.png

I need:

 

2021-05-06 02:25 PM

eliotcole
Responsive Resident
Responsive Resident

Can you confirm what happens when you perform this, please @datedlime?:

formatDateTime(utcNow(), 'g')

 

Also, when the flow runs, can you please copy the output of the step that this is taking the information from? Because "triggerOutputs" and "'body/receivedDateTime" don't look how I've seen this stuff done before, and you might be into some different, more advanced type of triggers.

 

I just used the trigger here, with this:

 

 

formatDateTime(triggerBody()['date'], 'g')

 

 

And it also worked. 

 

...

 

EDIT - A pure shot in the dark, but could you try this?:

 

formatDateTime(triggerBody()['receivedDateTime'], 'g')

 

 or perhaps either of these?:

 

formatDateTime(triggerOutputs()['body']['receivedDateTime'], 'g')
formatDateTime(triggerOutputs()['body']?['receivedDateTime'], 'g')

 

 

 

There is a screenshot of it in my previous post. It gets formatted like this:

 

562021 225 PM

eliotcole
Responsive Resident
Responsive Resident

Yeah, I saw that, I'm after the data as it comes in, from the trigger. 

 

When the test/run completes, go to the flow history, then look at the trigger in a given run, and copy the text that contains the output.

 

For example, to get this from a simple flow button trigger, I had to look at the raw output of the trigger, and I could see the body text:

    "body": {
        "date": "2021-05-06"
    }

 

Additionally, please look at the updates in my previous post, I think they might help.

Thanks for your continued help understanding this issue. 

 

The outputs for all three formulas you suggested result in the same text:

5102021 240 PM

 

This is my current existing code, which I've modified to change to the local time zone:

formatDateTime(convertTimeZone(triggerOutputs()?['body/receivedDateTime'],'Central Standard Time','Central Standard Time'),'yyyy-MM-dd hh:mm tt')

 

When I check the flow for output on the trigger after running my existing code, the output says:

    "body": {
        "Filename": "2021-05-10 0948 AM",
     }

 

The input within the same trigger says:

    "parameters": {
        "conversion/fileName": "2021-05-10 09:48 AM",
    }

 

It's interesting to me that the input includes the colon in the time, but the output doesn't. 

 

I am using "Export email (V2)" in the step prior, and the Output on that step includes:

 "body": "Received: from DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) by\r\n SJ0PR10MB4639.namprd10.prod.outlook.com with HTTPS; Mon, 10 May 2021 14:48:49\r\n +0000\r\n

 

eliotcole
Responsive Resident
Responsive Resident

Ah.

 

You are trying to make a file, correct? And you're using the date as the filename.

 

You can't have a colon in a filename, the flow is correcting this for you.

 

---

 

I have used a simple "replace()" function a few times in this expression to make a filename that you could easily organise:

replace(replace(replace(formatDateTime(triggerOutputs()?['body/receivedDateTime'], 'g'), '/', '-'), ':', '-'), ' ', '--')

 

What follows is an example of how I would recommend you export your email.

 

What I would suggest is that you create the exact same flow as this, separately to the flow that you're having issues with, so that you understand how it is put together.

 

Once you have that, you can then use it with whatever logic you already have:

email export flowemail export flow

 

Like I say ... You can wrap any other logic you have around this, just use it as an example:

View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA 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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,309)