cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
patriciocarpio
Frequent Visitor

Filter and Lookup not working with date values

Hello all,

 

I have an app whit a date picker. I use that value to try to filter a data source (comming from an Azure SQL database).

I use the following formula on a gallery:

Filter('[dbo].[Inspection]', Date=dpDate.SelectedDate)

and this on a label:

LookUp('[dbo].[Inspection]', Date=dpDate.SelectedDate, InspectionID)

I get not records on the first formula and nothing on the second formula. If I filter for another fields, I get records.

If I change the first formula to:

Filter('[dbo].[Inspection]', Date<>dpDate.SelectedDate)

I get all records.

 

Any ideas? What is the date value passed to SQL?

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @patriciocarpio,

 

What is the data type for the date field under SQL Server table?

Currently Date type from SQL Server can't work with PowerApps (a known issue), if possible, please switch to DateTime type.

Besides, by using the equal sign, the workable around here is:

 

Filter('[dbo].[Inspection]', DateValue(text(Date))=dpDate.SelectedDate)

Here we use DateValue( Text() ) together to format the DateTime Type from SQL Server to make it in the same format as DatePicker in PowerApps.

 

Doing this would make the formula in delegation limitation, which then could only work with the first 500 records.

See the article below for delegation:

Delegation

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-micsh-msft
Community Support
Community Support

Hi @patriciocarpio,

 

What is the data type for the date field under SQL Server table?

Currently Date type from SQL Server can't work with PowerApps (a known issue), if possible, please switch to DateTime type.

Besides, by using the equal sign, the workable around here is:

 

Filter('[dbo].[Inspection]', DateValue(text(Date))=dpDate.SelectedDate)

Here we use DateValue( Text() ) together to format the DateTime Type from SQL Server to make it in the same format as DatePicker in PowerApps.

 

Doing this would make the formula in delegation limitation, which then could only work with the first 500 records.

See the article below for delegation:

Delegation

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi Michael,

Following on from this issue, is the same fix intended to apply to performing the same function as a LookUp?

 

i.e.

LookUp('[dbo].[Inspection]',DateValue(Text(Date))=dpDate.SelectedDate,InspectionID)

If so, will it work if the field in the SQL server table is smalldatetime?

 

I have tried the following but to no avail

LookUp('[dbo].[tRoster]',DateValue(Text(srRosterDate))=DatePicker1.SelectedDate,srID)
MasterB
Advocate II
Advocate II

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,808)