web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : V2aIukzpoYNYx86L1qtaBD
Power Automate - Building Flows
Answered

Filtering a a text column containing 'date and time' in a SharePoint List

Like (0) ShareShare
ReportReport
Posted on 2 Nov 2022 07:18:11 by 195

Hi,

 

I currently have a SharePoint list and when a task is completed on a corresponding Planner, it updates the column 'Task Completed' with the date and time, the date is in format DD/MM/YYYY which is due to our location, the time is UTC time I believe (another flow get's the information from the 'Completed Date Time' of the task).

roxy1_0-1667374814046.png

Column settings:

roxy1_0-1667375859252.png

 

 

 

Unfortunately I made this column in the list a text column, and I am having trouble filtering all tasks completed in the past month.

 

The below does not work - I think it is because the column is text, contains the time, as well as the different date format of dd/mm/yyyy as showing in the test flow run:

roxy1_0-1667376503390.png

 

 

 

roxy1_0-1667373466439.png

First expression used in this filter query is formatDateTime(startOfMonth(getPastTime(1,'Month')),'MM-dd-yyyy')

The second expression used is formatDateTime(startOfMonth(utcNow()),'MM-dd-yyyy')

 

(sorry if you end up answering my queries again @grantjenkins 😂)

  • roxy1 Profile Picture
    195 on 03 Nov 2022 at 07:07:58
    Re: Filtering a a text column containing 'date and time' in a SharePoint List

    @v-chengfen-msft Sorry I need your help again - I thought the above fixed it, but it is still pulling data from the incorrect year. It pulling dates from the right month, but both in 2021 and 2022. The formatting has not changed in the column on the same list so I at a loss!

     

    roxy1_0-1667459270335.png

     

     

    roxy1_0-1667460096234.png

     

  • Verified answer
    roxy1 Profile Picture
    195 on 03 Nov 2022 at 06:50:40
    Re: Filtering a a text column containing 'date and time' in a SharePoint List

    Solved my own query - the date in the text column was formatted 1/10/22 (not with hyphens!)

     

    I changed the expression to the following which worked:

     

    formatDateTime(startOfMonth(getPastTime(1,'Month')),'MM/dd/yyyy 00:00:00')

  • roxy1 Profile Picture
    195 on 03 Nov 2022 at 06:13:56
    Re: Filtering a a text column containing 'date and time' in a SharePoint List

     I've managed to hard code the time in so it searches from midnight to midnight using the expressions:

     

    formatDateTime(startOfMonth(getPastTime(1,'Month')),'MM-dd-yyyy 00:00:00')

    formatDateTime(startOfMonth(utcNow()),'MM-dd-yyyy 00:00:00')

     

     

    Though some reason the results (this also happened before I changed the expression) it brings back are items from that column from the completely different month as well as year!

     

     

     

    roxy1_0-1667457878829.png

     

     

    roxy1_1-1667457948254.png

     

     

  • roxy1 Profile Picture
    195 on 03 Nov 2022 at 01:04:40
    Re: Filtering a a text column containing 'date and time' in a SharePoint List

    Hi @v-chengfen-msft ah wonderful - so simple when the solution is shown to me! Thank you!

     

    Did you do the 'compose' step just to show me the output in your example?

  • Verified answer
    v-chengfen-msft Profile Picture
    on 02 Nov 2022 at 09:16:03
    Re: Filtering a a text column containing 'date and time' in a SharePoint List

    Hi @roxy1 ,

    Please try :

    First expression used in this filter query formatDateTime(startOfMonth(getPastTime(1,'Month')),'MM-dd-yyyy hh:MM:ss')

     

    The second expression used is formatDateTime(startOfMonth(utcNow()),'MM-dd-yyyy hh:MM:ss')

    Here is test for your reference:

    vchengfenmsft_0-1667380525509.png

     

    vchengfenmsft_1-1667380525528.png

     

    Here is result:

     

    vchengfenmsft_2-1667380525543.png

     

     

     

    Best Regards

    Cheng Feng

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete