cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to compare dates in two SH Lists

Dear community,

 

I would like to compare the date in two different list and then continue working with the result. I am only interested in the day, not the time. But in my lists the time is also kept. The exact working time is irrelevant and varies often.

 

About the scenario:
1. each student has his own list for his activities.

2. for accounting there is a total list with all students and their plan data.

3. another flow imports from Microsoft Shifts the plan data. This one works flawlessly.

Now I want to check in the accounting list if the created activity (actually working day) already exists for this day from a certain student as plan data.

 

Therefore, I first check whether there is a shift for this day and then for whom this shift is entered.
However, I am already stuck at the first step.

 

My trigger is "When a new item is created" (student list). The second action is to load the accounting list.
Now I want to check for each entry if it corresponds to this date. However, it does not work. It always shows me that for formatDateTime "Null" is passed instead of "String".

 

Can someone help me? How could I do it differently? I have tried a lot, but I can't find a solution.

 

 

left:  formatDateTime(triggerBody()?['Arbeitsbeginn'], 'ddMMyyyy') 
right: formatDateTime(outputs('Buchungsliste_abrufen')?['PlanStart'], 'ddMMyyyy')

 

PA.png

 

3 REPLIES 3
jinivthakkar
Super User
Super User

@Anonymous :

 

Here is my list, instead of two list I took two columns in the same list 

jinivthakkar_0-1611081166594.png

My flow : 

jinivthakkar_1-1611081208633.png

jinivthakkar_2-1611081304021.png

 

jinivthakkar_3-1611081342030.png

 

This just works fine, if the dates are same the condition outcome is true else it is false.

 

 

formatDateTime(utcNow(),'yyyy-MM-dd') /*gets formats UTC*/

formatDateTime(outputs('Get_item')?['body/MeetingTime'],'yyyy-MM-dd')  /*formats dynamic date*/

 

I don't know why you are facing the issue, just try this one.

 

Also why don't you have a scheduled flow which runs daily, and queries list to find which items have today's date/due date and then implement your logic, this way you will not have to iterate through all items.

 

Hope this helps.

Anonymous
Not applicable

First of all, thank you very much for your reply.


I only create my activity report once a day, so I also only have to iterate once for each student. So that is not the problem.

 

I can't set the variables like you do, because I get an error message that I am not allowed to do the variable setting in the loop. And thats what i need.

 

I have also tried to work around this in the SH lists using =TEXT([DateTime], 'dd-mm-yyyy'), but I get a syntax error every time, even though DateTime is of type DateTime and every other tutorial uses it exactly like that. I don't know why.

jinivthakkar
Super User
Super User

@Anonymous I was able to set variables like this, you can initialize variable outside the loop and set variable in the loop.

 

jinivthakkar_0-1611138200383.png

 

jinivthakkar_1-1611138294663.png

 

hope this helps

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,864)