cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerSalam
New Member

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
Resident Rockstar
Resident Rockstar

@PowerSalam :

 

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.

PowerSalam
New Member

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
Resident Rockstar
Resident Rockstar

@PowerSalam 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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,972)