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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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