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!


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. 

Highlighted
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
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,873)