cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Giovanni1
Helper III
Helper III

Filter in a table sql

Hi everyone, in an sql table, I have a DATAAPP (char8) date field "20210915" and in my app I have a datapicker. I need to filter in the table all records whose date is greater than my datepicker. I tried but when I enter (DATAAPP> Label38.text) in the Filter, I have an error, while (DATAAPP = Label38.text) does not give an error. Could you give me some advice? Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@Giovanni1 

The reason for this problem is that it's not possible to carry out numeric greater than/less than comparisons when the source data types are strings.

 

The way I would resolve this would be to create a SQL Server view that converts your char8 field to the data type date. This is how the view would look.

 

CREATE VIEW yourView
  AS
SELECT 
  CAST( YourCharDateField AS date) AS YourDateField,
  OtherField1,
  OtherField2
FROM
  YourTable


You can then connect to this view from your app and filter the records using the greater than or less than operators operators.

Filter(YourView, YourDateField >= DatePicker1.SelectedDate)

 

The benefit of this solution is that the filter operation will be delegable in Power Apps.

View solution in original post

1 REPLY 1
timl
Super User
Super User

@Giovanni1 

The reason for this problem is that it's not possible to carry out numeric greater than/less than comparisons when the source data types are strings.

 

The way I would resolve this would be to create a SQL Server view that converts your char8 field to the data type date. This is how the view would look.

 

CREATE VIEW yourView
  AS
SELECT 
  CAST( YourCharDateField AS date) AS YourDateField,
  OtherField1,
  OtherField2
FROM
  YourTable


You can then connect to this view from your app and filter the records using the greater than or less than operators operators.

Filter(YourView, YourDateField >= DatePicker1.SelectedDate)

 

The benefit of this solution is that the filter operation will be delegable in Power Apps.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,622)