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

Notifications

Announcements

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,508 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,508 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,508 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,508 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard