cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Having trouble with getting today's date for a condition

Hello

My Flow depends on a column (Future Approval Date) equals Today. I live in Australia so date format is dd/MM/yyyy

 

What I have so far is if 'Future Approval Date' is equal to formatDateTime(utcNow(),'ddMMyyyy') (which needs to be Today) then proceed.

 

I've tried just utcNow() and put in a convert time zone as well and that doesn't work either.

Not sure if convert time zone is necessary but I've been battling with this for a long time. Flow just goes down the No side and doesn't work.

 

1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hi @xxxxmints did you try the suggestion made by @v-bacao-msft?

 

Ideally when you're comparing two dates in the way that you want you would just convert both sides to a string, strip off the time and concentrate on the dates in the format yyyy-MM-dd.

 

So you could use formatDateTime(utcNow(),'yyyy-MM-dd') to get todays date, and formatDateTime(<mydynamiccontent>,'yyyy-MM-dd') to format the comparison. Take note of the date format as that is the most common and robust way of formatting as it will work regardless of timezone or date format. I commonly use this when I need to compare dates in UK format to those in a US format.

 

formatDateTime.PNG





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

16 REPLIES 16
Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Im in australia and hate working with dates too.

 

Dont know if it will help but i think your convert time zone is wrong. it should be "(UTC) Coordinated Universal Time"

 

The best thing for you to do is to chuck in some compose actions with the two sides of your condition and compare them to see why they do not match. SharePoint Date/Time column's always have a time in them even if not set i.e. 00:00 so you may have more luck with contains rather than equals.

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

Hi thanks for your response.

I changed it to the correct univesal time.

I'm not sure what you mean by compose actions. Can you explain further?

Highlighted
Frequent Visitor

Re: Having trouble with getting today's date for a condition

Search for Compose in the actions.

Add a couple of them,

 

In one put the data from SharePoint in the Other put your output from the converted date and time.

 

Once the flow runs, look at the run history and you will see exactly what each side of the condition looks like.

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

I found the issue.

 

Firstly I did a couple of other things. I followed this tutorial on creating a TodayDate column.

 

Then I said if Future Approval Date = TodayDate then etc etc

 

While looking at the compose actions, I noticed the Flow started working after midday today. Even though I have convert time zone, for some reason it is running behind. Not sure how to fix that  but my condition works, which is the main thing. 

 

Do you have any further ideas on how to fix the time issue?

Thanks for your help so far 🙂

Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Please show the examples of what you mean 🙂

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

Not sure how to show examples

The TodayDate was one day behind up until midday. As soon as midday clicked over, it changed.

 

1.png2.png

 

Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hi,

 

Sorry i meant after the flow has run, you can inspect it and see what values actually are.

 

It looks like you are not using the converted time at all though, you are using a SharePoint Column rather than the output of the conversion action

 

 

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

Ok, thank you 🙂
Can you tell me how I use the converted time? I didn't see anything on that when I was looking at tutorials.

Should I put TodayDate in the base time field?

Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hey, if you click in the condition, you should see in the dynamic data the output from the action instead of the sharepoint icon it will have the same icon.

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

I'm sorry but you have completely lost me.

Highlighted
Community Support
Community Support

Re: Having trouble with getting today's date for a condition

 

Hi @xxxxmints ,

 

For example, you can first enter the two Dates you want to compare in Compose.

The above represents today's date, the following represents Created Date, and uses the formatDateTime() function to modify them to the format of yyyy-MM-dd.

Then in the Flow run history to see the value of the two Dates in the compose.

Image reference:

193.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hey,

 

So in your condition - you have selected Dynamic Data i.e. TodaysDate from what looks like the Trigger.

 

Delete TodaysDate with the SharePoint S icon.

 

Click into that area and the pop-up with Dynamic Data will come up.

 

You will want to insert the converted date from the convert time zone

 

Take a look here:

 

Annotation 2019-09-19 101824.png

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

Hi there
I have done as you suggested and then after convert time zone I have Update Item, and put converted time into TodayDate field. I also put it in the Title field to check the date.

The flow throws an error and says:

 

"status": 400,
"message": "String was not recognized as a valid DateTime.

 

I checked the title column and the date is correct and in the correct format (dd/MM/yyyy). But it is not happy in the TodayDate field - I can't work out why.

 

I have checked the regional settings on the library and they are correct and I even checked the TodayDate column and made sure it is friendly (I even tried Standard but that made no difference either).

Do you know why this is happening now?

Thanks again.

Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hey,

 

That is not the correct format for a update item action.

 

I think it is the one ending [u] that has to be used. I tried to find a flow to confirm but cannot find one i have built before using this.

Highlighted
Super User
Super User

Re: Having trouble with getting today's date for a condition

Hi @xxxxmints did you try the suggestion made by @v-bacao-msft?

 

Ideally when you're comparing two dates in the way that you want you would just convert both sides to a string, strip off the time and concentrate on the dates in the format yyyy-MM-dd.

 

So you could use formatDateTime(utcNow(),'yyyy-MM-dd') to get todays date, and formatDateTime(<mydynamiccontent>,'yyyy-MM-dd') to format the comparison. Take note of the date format as that is the most common and robust way of formatting as it will work regardless of timezone or date format. I commonly use this when I need to compare dates in UK format to those in a US format.

 

formatDateTime.PNG





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

Highlighted
Helper II
Helper II

Re: Having trouble with getting today's date for a condition

Thank you, thank you, thank you. 

Helpful resources

Announcements
firstImage

Now Live: 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
Users online (8,765)