cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gazzaluty
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
gamoraes
Memorable Member
Memorable Member

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

v-micsh-msft
Community Support
Community Support

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
gamoraes
Memorable Member
Memorable Member

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

v-micsh-msft
Community Support
Community Support

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

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

gamoraes
Memorable Member
Memorable Member

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!


It shows the same error even when I do that.

 

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

 

It looks like an issue with excel. 

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

 

thanks,

Ibrahim 

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

 

Has anyone found a workaround?

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (1,115)