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

Date and Time Conditions/Expressions

Hello,

 

I am trying to build a flow that runs on a weekly schedule, checking for items (in a SharePoint List) that have been created more than one year ago.  If an item has not been created more than a year ago, then the flow takes no further action.  But, if the item has been created more than a year ago, then flow will take steps to move that item to a separate SharePoint List.

 

I mostly have things figured out (I think), but am having a lot trouble figuring out what the correct expression would be (to test whether or not an item has been created more than a year ago).  So far, I have:

 

@equals(items('Apply_to_each')?['Created'], utcNow(addDays(365)))

 

Creating expressions is definitely something that I have long struggled with, so any help you could provide would be much appreciated!

 

Thanks a bunch!

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @Anonymous,

 

Do you want to check items that have been created more than one year ago and save them into another list?

 

I have made the following test. As I don’t have an item created one year ago, so I create a Date column. It is trigged by a Button, while you could change it to a Recurrence trigger according to your needs.

 

In the Condition, use the following code:

@equals(formatDateTime(items('Apply_to_each_2')?['Date'], 'yyyy-MM-dd'),formatDateTime(adddays(utcnow(),-365),'yyyy-MM-dd'))

Note: Make sure you have formatted the two dates into the same format.

 

The flow is configured as below and it works fine. Please take it for a reference.

1.PNG

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
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

2 REPLIES 2
v-yamao-msft
Community Support
Community Support

Hi @Anonymous,

 

Do you want to check items that have been created more than one year ago and save them into another list?

 

I have made the following test. As I don’t have an item created one year ago, so I create a Date column. It is trigged by a Button, while you could change it to a Recurrence trigger according to your needs.

 

In the Condition, use the following code:

@equals(formatDateTime(items('Apply_to_each_2')?['Date'], 'yyyy-MM-dd'),formatDateTime(adddays(utcnow(),-365),'yyyy-MM-dd'))

Note: Make sure you have formatted the two dates into the same format.

 

The flow is configured as below and it works fine. Please take it for a reference.

1.PNG

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

To answer your question, yes.  The goal is to check items on a list, saving them to a different list if they have been created more than one year ago.

 

Which is what I believe your expression below does.  For testing purposes, if I changed -365 to -1, that shouldn't break anything right?  It would just change the flow so that it looks for items older than one day instead of one year?

 

Thanks a bunch for all your help, I really appreciate it. 🙂

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 (6,871)