cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Compare DateValues in Strings with DatePicker SelectedDate

What am I missing here!? I must be tired. 

Scenario:

- Gallery full of Filenames

- Filename example = 003907302020UMT002.xlsx

  - 4 digit numeric prefix

  - mmddyyyy date

  - 6 char suffix

  - File extension

 

- App has two date pickers: Start Date and End Date

 

- Trying to filter gallery where filename date portion is greater than Start Date and less than End Date

- Mid(ThisItem.Filename, 5, 8 ) gets me what looks correct: 07302020, but this is not a DateValue to compare against the DatePicker SelectedDates

- However DateValue(Mid(ThisItem.Filename, 5, 8)) returns: 8/20/731!

- Tried DateValue(Text(Mid(ThisItem.Filename, 5, 8), "mmddyyyy")) but this also returns 8/20/731

 

Whats going on here? 

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @ericonline ,

Try

With(
    {
        wDate: Mid(
            ThisItem.Filename,
            5,
            8
        )
    },
    DateValue(
        Left(
            wDate,
            2
        ) & "/" & Mid(
            wDate,
            3,
            2
        ) & "/" & Right(
            wDate,
            4
        )
    )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Top Kudoed Authors
Users online (2,496)