cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jup
Helper II
Helper II

Filter Date in SQL

Hi all,

 

if just want to filter my gallery on a date field. Something like:

 

SortByColumns(    
         Filter('[dbo].[tTime]'; Date=Text(_dateSelected; "[$-de-DE]yyyy-mm-dd") & " 00:00:00.000")
; "Date")

But it doesn't work.

I'm using the CalendarScreen for my example:

 

1.PNG

Here's a screenshot of my database table (field "date"):

 

2.PNG

Can you help me please?

 

thanks

jup

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

From the documentation on SQL delegation limitations

 

Direct date filters do not work for SQL Server. However, you can create a calculated column that will work. For instance, ALTER TABLE myTable ADD DateAsInt AS (YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date])) and then filter on the calculated number column.

 

To filter on the date with delegation you'll need to add a calculated column to your SQL Table.

The other possibility that might also work would be to do your Filter statement at two levels like this:

Filter(Filter('[dbo].[tZeit]';PersonalNr=1513),Text(Datum;"[$-de-DE]yyy-mm-dd")="2017-01-71")

This will work even though the Date filter isn't delegable IF the filter on PersonalNr can get the record set below 500 records returned. So this strategy depends on your data.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
Pstork1
Dual Super User III
Dual Super User III

Put a Text() formatting function around the Date field also so both sides of the equation are considered text.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

No. Sorry. Doesn't work:

 

Filter('[dbo].[tZeit]'; Text(Datum)="2017-05-01 00:00:00.000")

 

Doesn' t work,too:

 

Filter('[dbo].[tZeit]'; Text(Datum;"[$-de-DE]")="2017-05-01 00:00:00.000")

any idea?

I got (a little bit)...

but other question:

 

If I use this formula - it works great:

1.PNGI get the results of my formula 🙂

 

BUT if I want to use a 2nd filter condition, the formula will be underlined blue and I'll get no results (because of "Delegation limit"):

2.PNG

 

How can I solve this problem?

 

Thanks,

jup

yashag2255
Dual Super User II
Dual Super User II

Hi @jup 

 

Can you please try to modify your expression as:
 
SortByColumns(   
         Filter('[dbo].[tTime]'; DateValue(Text(Date))=DateValue(Text(_dateSelected; "[$-de-DE]yyyy-mm-dd")))
; "Date")
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Pstork1
Dual Super User III
Dual Super User III

From the documentation on SQL delegation limitations

 

Direct date filters do not work for SQL Server. However, you can create a calculated column that will work. For instance, ALTER TABLE myTable ADD DateAsInt AS (YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date])) and then filter on the calculated number column.

 

To filter on the date with delegation you'll need to add a calculated column to your SQL Table.

The other possibility that might also work would be to do your Filter statement at two levels like this:

Filter(Filter('[dbo].[tZeit]';PersonalNr=1513),Text(Datum;"[$-de-DE]yyy-mm-dd")="2017-01-71")

This will work even though the Date filter isn't delegable IF the filter on PersonalNr can get the record set below 500 records returned. So this strategy depends on your data.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,627)