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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trying to add a filter...
Power Apps
Unanswered

Trying to add a filter to a gallery based on datepicker from a sql datasource. The date format is YYYY-mm-dd.

(0) ShareShare
ReportReport
Posted on by 46

When I add a filter to the a SQL datasource gallery and I add a datepicker to allow me to filter the records on date.   SQL displays the date as YYYY-MM-dd.  Datepicker is showing date as MM\dd\YYYY.   When I enter a date that I know I have data for, no data is display.  I don't get an error in the formula.

 

Formula for Gallery.items:  Filter(vw_Expenses, Date = dp_ViewExpensesDateFilter.SelectedDate)

 

Nothing is displayed.  Is it because SQL displays dates as YYYY-MM-dd?  If so, how do I fix this?  If not, what is the recommended change to get the filter working on my gallery?

Categories:
I have the same question (0)
  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    You can format the selected date and then this will be an exact match to your records in SQL.

     

    Look at DateTimeValue() function within your filter.

  • ashajohn2021 Profile Picture
    46 on at

    I added both Datetimevalue() and datevalue, nothing changed:  Filter(vw_Expenses,Date = DateValue(dp_ViewExpensesDateFilter.SelectedDate,"yyyy-mm-dd"))

     

    I tried adding Text in front of the formula, but I got the Incompatible type message.  

     

    Any suggestions?

  • ashajohn2021 Profile Picture
    46 on at

    BTW, This is a shortdate field not a datetime.

  • ashajohn2021 Profile Picture
    46 on at

    I found this solution in a different post.  I got results this time, but the filter is not working.  Anyone see where the problem is?  Filter(vw_Expenses,DateValue(Text(Date, "en-US")) = DateValue(Text(dp_ViewExpensesDateFilter.SelectedDate, "en-US")))

     

    Here is where I got this from:  https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-using-date-field-from-SQL-Server/td-p/149691

  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    Can you add the two dates to a label and show me the output? 

  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    Can you show me what you mean when you say you get results but the filter isn't working?

  • ashajohn2021 Profile Picture
    46 on at

    Here is the filter

    ashajohn2021_0-1655127729670.png

     

    When I run the app, I enter a date and you can see the filter was not applied:

    ashajohn2021_1-1655127815410.png

     

    Here is a print screen with the datepicker value on the top and the date field in the gallery.  I see the problem is in the formatting.  Can you help me fix? Not sure what to do. Thank you!

     

  • ashajohn2021 Profile Picture
    46 on at

    ashajohn2021_2-1655128897513.png

     

  • ashajohn2021 Profile Picture
    46 on at

    I didn't set datetime in SQL on the field.  I'm not sure why it's displaying as datetime in the gallery.  It was always have a time of 12:00 am because it's just a date field in SQL.

  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    Is your date a date only or a date time?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard