cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gazzaluty
Level: Power Up

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

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

Community Support Team
Community Support Team

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

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

Community Support Team
Community Support Team

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

Gangula
Level: Powered On

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

Super User
Super User

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
Gangula
Level: Powered On

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. 

Ibrahimkhalil
Level: Powered On

Re: Compare dates

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

 

thanks,

Ibrahim 

Naz
Level: Powered On

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?

Gangula2
Level: Power Up

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 314 members 4,625 guests
Please welcome our newest community members: