cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Compare dates

@equals(items('Apply_to_each')?['Start_x0020_Date'], addDays(utcnow('yyyy-MM-dd'), -7))

 

Start Date  = 30/08/2017

 

Anyone any ideas about evaulating dates? 

 

If i email the variables through when this is not equal i get...

 

2017-08-30T09:42:29.5176527Z 2017-08-30

 

Thanks,

Gaz

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Power Participant
Power Participant

Re: Compare dates

hi @Gazzaluty

 

The best way in my vision is transform dates to ticks and compare then

 

in this case your condiction should be:

 

 

@equals(ticks(items('Apply_to_each')?['Start_x0020_Date']), ticks(addDays(utcnow(), -7)))

 

OBS: if you need to compare only date without values you may transform the date before, removing the time value, like this:

 

@equals(ticks(concat(formatDateTime(triggerBody()?['Start_x0020_Date'], 'yyyy-MM-dd'), 'T00:00:00Z')), ticks(concat(formatDateTime(addDays(utcnow(), -7), 'yyyy-MM-dd'), 'T00:00:00Z')))

 

if you have questions about the functions you can put one per one in a compose to see the result.

 

Hope this help.

 

Best Regards,

 

Gustavo Moraes


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

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

Highlighted
Community Support
Community Support

Re: Compare dates

Hi @Gazzaluty,

 

As suggested by @gamoraes, when comparing date string, we should first format both of the date string into a same format:

@equals(formatDateTime(triggerBody()?['Start_x0020_Date'], 'yyyy-MM-dd'), 
        formatDateTime(addDays(utcnow(), -7), 'yyyy-MM-dd')
           )

Doing it in this way should make it work, if the condition is focus on date.

 

Regards,

Michael

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

8 REPLIES 8
Highlighted
Power Participant
Power Participant

Re: Compare dates

hi @Gazzaluty

 

The best way in my vision is transform dates to ticks and compare then

 

in this case your condiction should be:

 

 

@equals(ticks(items('Apply_to_each')?['Start_x0020_Date']), ticks(addDays(utcnow(), -7)))

 

OBS: if you need to compare only date without values you may transform the date before, removing the time value, like this:

 

@equals(ticks(concat(formatDateTime(triggerBody()?['Start_x0020_Date'], 'yyyy-MM-dd'), 'T00:00:00Z')), ticks(concat(formatDateTime(addDays(utcnow(), -7), 'yyyy-MM-dd'), 'T00:00:00Z')))

 

if you have questions about the functions you can put one per one in a compose to see the result.

 

Hope this help.

 

Best Regards,

 

Gustavo Moraes


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

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

Highlighted
Community Support
Community Support

Re: Compare dates

Hi @Gazzaluty,

 

As suggested by @gamoraes, when comparing date string, we should first format both of the date string into a same format:

@equals(formatDateTime(triggerBody()?['Start_x0020_Date'], 'yyyy-MM-dd'), 
        formatDateTime(addDays(utcnow(), -7), 'yyyy-MM-dd')
           )

Doing it in this way should make it work, if the condition is focus on date.

 

Regards,

Michael

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
Advocate II
Advocate II

Re: Compare dates

This method doesn't seem to work with me.

 

I have an excel table with a column for dates. I'm trying to see if the dates in that column are in next week. 

But I keep getting an error when I use the below exression

 

@lessOrEquals(ticks(items('Apply_to_each')?['Date']), ticks(addDays(utcnow(), 7)))

Below is the screenshot of the error.

2018-09-24_22-26-10.png

Highlighted
Power Participant
Power Participant

Re: Compare dates

Hey Wasup?

 

I think you forgot to put 'FormatDateTime'

 

@lessOrEquals(ticks(formatDateTime(items('Apply_to_each')?['Date'])), ticks(addDays(utcnow(), 7)))

 


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

Gustavo Moraes, o astronauta brasileiro do Flow!


Highlighted
Advocate II
Advocate II

Re: Compare dates

It shows the same error even when I do that.

 

2018-09-25_11-18-18.png

 

It looks like an issue with excel. 

Highlighted
Helper I
Helper I

Re: Compare dates

yes im having the same problem, can anyone help please?

 

thanks,

Ibrahim 

Highlighted
Helper I
Helper I

Re: Compare dates

Yes. Excel formats dates as numbers whereas flow expects it to come through in a string format.

 

Has anyone found a workaround?

Highlighted
New Member

Re: Compare dates

This solution seems to be working for me. But I used it with "equals to" condition. I'm not sure if it works with other logic's.

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

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!

Top Solution Authors
Top Kudoed Authors
Users online (14,170)