cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Edina
Helper I
Helper I

Formatting date only

Hi,

 

I have an expiry dat that returns as 2021-01-25T08:00:00Z and I want to compose an email stating what is the expiry date in this format: 25 Jan 2021. I tried using 

 

formatDateTime(triggerBody()?['Expiry Date'],'dd/MM/yyyy')

 

but it doesn't work. it gives me this error 

 

InvalidTemplate. Unable to process template language expressions in action 'Send_an_email_notification_(V3)' inputs at line '1' and column '14342': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

 

 

Please help me. Thank you in advance

2 ACCEPTED SOLUTIONS

Accepted Solutions
ViditGholam
Responsive Resident
Responsive Resident

Hi @Edina you can do it as shown below

Put your expire date in a string variable and use that variable in your date formatter

ViditGholam_0-1617091841717.png

Output - 

ViditGholam_1-1617091871089.png

Hope this helps !

Let me know in case any issues 

If this solves your problem please mark this post as answered and hit me a thumps up.

 

Thanks and Regards,

Vidit 

View solution in original post

ViditGholam
Responsive Resident
Responsive Resident

@Edina you will have to initialize a variable some where up in your flow and then set that variable for example look at this flow 

ViditGholam_0-1617092962098.png

connectors - 

ViditGholam_1-1617093000101.png

it is just like how we define variables in a code and then use or set them as and when needed.

 

View solution in original post

23 REPLIES 23
DamoBird365
Community Champion
Community Champion

Hi @Edina 

 

You need to check that triggerBody()?['Expiry Date'] is actually returning what you expect.

 

Try it in a compose first.  When you use a ? in an array expression it will return NULL if it cannot be evaluated.  Remove the ? and the expression will fail.  So I guess there is a typo in there somewhere.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

ViditGholam
Responsive Resident
Responsive Resident

Hi @Edina you can do it as shown below

Put your expire date in a string variable and use that variable in your date formatter

ViditGholam_0-1617091841717.png

Output - 

ViditGholam_1-1617091871089.png

Hope this helps !

Let me know in case any issues 

If this solves your problem please mark this post as answered and hit me a thumps up.

 

Thanks and Regards,

Vidit 

View solution in original post

Hello @ViditGholam !

 

I am trying to convert to string but I face this issue (in pic). I am unable to put anything under the name portion. 

Edina_1-1617092735351.png

 

Able to advice me on how I should do this?

ViditGholam
Responsive Resident
Responsive Resident

@Edina you will have to initialize a variable some where up in your flow and then set that variable for example look at this flow 

ViditGholam_0-1617092962098.png

connectors - 

ViditGholam_1-1617093000101.png

it is just like how we define variables in a code and then use or set them as and when needed.

 

View solution in original post

ViditGholam
Responsive Resident
Responsive Resident

also try what @DamoBird365  said even I feel there is a typo in there try removing triggerBody()"?"['Expiry Date']

"?" from your previous expression.

DamoBird365
Community Champion
Community Champion

Hi @Edina 

 

I think you are over complicating.  Personally I would strip back the 2nd apply to each and if you are new to Power Automate create the following flow actions:

DamoBird365_0-1617093178454.png

 

This would return the following:

DamoBird365_1-1617093242472.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

It works! Thank you @ViditGholam 😄

Edina
Helper I
Helper I

Hello @ViditGholam 

 

Can I check with you regarding another question?

 

Edina_0-1617097118509.png

As seen in the picture, the output is 1 and the condition I set is as follows

Edina_1-1617097308061.png

 

May I know why is the expression result false?

 

ViditGholam
Responsive Resident
Responsive Resident

@Edina try it out this way 

ViditGholam_2-1617098416800.png

 

ViditGholam_1-1617098373281.png

@ViditGholam its the same Edina here. 

 

I tried 

string('Due')

and the output is "Due".

Edinaa_0-1617157440746.png

The data in Due is Yes/No or 1/0. How can I write an expression that gets the data instead of the word "Due"?

ViditGholam
Responsive Resident
Responsive Resident

Hi, @Edinaa so if the data in that "Due" is Yes or no which means true/false just use this instead and check if it works

ViditGholam_0-1617160731199.png

 

@ViditGholam I have tried this

Edinaa_0-1617161007335.png

But I got this

Edinaa_1-1617161030061.png

That was why I set the condition as equal to 1 yet it still did not work even if its 1.

ViditGholam
Responsive Resident
Responsive Resident

@Edinaa  go in the Dynamic contents -> Expression section -> type true and use that instead and check

@ViditGholam 

Edinaa_0-1617161369978.png

For the condition, I tried Due or WFIDue is equal to the expression true, condition is still false.

ViditGholam
Responsive Resident
Responsive Resident

@Edinaa make sure this Variable is initialized as a Boolean and not a string also I am checking on how to get the value instead 

ViditGholam_0-1617161563915.png

 

 

When I initialize the variable as Boolean, this error comes up: 

Edinaa_0-1617161723146.png

 

ViditGholam
Responsive Resident
Responsive Resident

@Edinaa I see also try without using a variable 

ViditGholam_0-1617161903119.png

Put Due directly in your condition 

@ViditGholam I have tried that as well and it comes out false as well 😞 

 

I'm not sure what's wrong

ViditGholam
Responsive Resident
Responsive Resident

give me some time I will check and let you know 

Helpful resources

Announcements
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

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (52,145)