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

Announcements

News and Announcements icon
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
    Microsoft Employee 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,041

#2
11manish Profile Picture

11manish 676

#3
Valantis Profile Picture

Valantis 655

Last 30 days Overall leaderboard