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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,883)