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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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