web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter Date in SQL by ...
Power Apps
Answered

Filter Date in SQL by Today with calculated column

(0) ShareShare
ReportReport
Posted on by 16

A few things I don't really understand.  

1.) My formula works on Database Mart SQL 2017  in the cloud

2.) My formula works on Azure SQL database in the cloud

3.) My formula doesn't work on SQL Server 2022 on prem

 

I read and understand Direct Date Filters Don't Work on SQL Server Tables, why does it work in Azure SQL and Database Mart then?  No one can answer this so far that I can find so moving on to the actual question below.

 

The Formula:

SortByColumns(Search(Filter([@'dailyLog'],DateAsInt=Today()), TextSearchBox1.Text, Address,Twp,Contractor,Permit,Type,Inspector), "Order", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

 

 

I did the "ALTER TABLE myTable ADD DateAsInt AS (YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date]))" and now end up with 20240515 for 2024-05-15.  How do I get my formula above to filter by today with the DateAsInt column?  I see post after post saying you need to do the above and sort based on the DateAsInt column but no one tells you how to do that.

Categories:
I have the same question (0)
  • wstone Profile Picture
    16 on at
    I've got this but it doesn't work either....I get "incompatible types for comparison. these types can't be compared number, text" What is the DateAsInt considered since its a calculated column? I can't get the date to format as "yyyymmdd"without the Text wrapper.

     

     

    SortByColumns(Search(Filter(dailyLog, DateAsInt=Text(Today(),"yyyymmdd")), TextSearchBox1.Text, Address,Twp,Contractor,Permit,Type,Inspector), "Order", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @wstone ,

     

    This is because DateAsInt column is of type number and Text function returns text value, they cannot be compared. Please add a Value function to include the Text function:

    vjefferni_0-1715925220069.png

    SortByColumns(Search(Filter(dailyLog, DateAsInt= Value(Text(Today(),"yyyymmdd"))), TextSearchBox1.Text, Address,Twp,Contractor,Permit,Type,Inspector), "Order", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard