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 Apps
Answered

Time Format

(0) ShareShare
ReportReport
Posted on by 94

Hi all

 

I have created a table that allows the user to filter for name, category, order no. and date. Each filter works as intended besides the date filter for which I want the user to select a date from a date picker and the table will show records for the selected date.

 

I was just wondering if the date picker can't find the date in the sql server database since the date picker format is dd/mm/yyyy and the sql date format is yyyy-mm-dd? Maybe it's just an issue with my code? 

 

If(
!IsBlank(DisplayName_3.Selected.Name) ||
!IsBlank(Categorycombo1_2.Selected.Categories) ||
!IsBlank(OrderNumber1_2.Selected.OrderDistinct) ||
!IsBlank(DatePicker2_1.SelectedDate),
Sort(
Filter(
Times,
(IsBlank(DisplayName_3.Selected.Name) || Name = DisplayName_3.Selected.Name) &&
(IsBlank(Categorycombo1_2.Selected.Categories) || Category = Categorycombo1_2.Selected.Categories) &&
(IsBlank(OrderNumber1_2.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_2.Selected.OrderDistinct) &&
(IsBlank(DatePicker2_1.SelectedDate) || Date = DatePicker2_1.SelectedDate)
),
Date,
SortOrder.Descending
),
Sort(
Times,
Date,
SortOrder.Descending
)
)

Best Regards

 

Categories:
I have the same question (0)
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi

    Try this

    Sort( Filter( Times, (IsBlank(DisplayName_3.Selected.Name) || Name = DisplayName_3.Selected.Name) && (IsBlank(Categorycombo1_2.Selected.Categories) || Category = Categorycombo1_2.Selected.Categories) && (IsBlank(OrderNumber1_2.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_2.Selected.OrderDistinct) && (IsBlank(DatePicker2_1.SelectedDate) || Date = Text(Year(DatePicker2_1.SelectedDate)) & "-" & Text(Month(DatePicker2_1.SelectedDate)) & "-" & Text(Day(DatePicker2_1.SelectedDate))) ), Date, SortOrder.Descending )

    Or

    If(
    !IsBlank(DisplayName_3.Selected.Name) ||
    !IsBlank(Categorycombo1_2.Selected.Categories) ||
    !IsBlank(OrderNumber1_2.Selected.OrderDistinct) ||
    !IsBlank(DatePicker2_1.SelectedDate),
    Sort(
    Filter(
    Times,
    (IsBlank(DisplayName_3.Selected.Name) || Name = DisplayName_3.Selected.Name) &&
    (IsBlank(Categorycombo1_2.Selected.Categories) || Category = Categorycombo1_2.Selected.Categories) &&
    (IsBlank(OrderNumber1_2.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_2.Selected.OrderDistinct) &&
    (IsBlank(DatePicker2_1.SelectedDate) || Date = Text(DatePicker2_1.SelectedDate, "[$-en-US]yyyy-mm-dd"))
    ),
    Date,
    SortOrder.Descending
    ),
    Sort(
    Times,
    Date,
    SortOrder.Descending
    )
    )


    Thanks!

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • R45 Profile Picture
    94 on at

    @Rajkumar_404 

     

    Thanks for your response. In both cases there is an incompatibility issue between text and date as you have wrapped the date in a text function. Any other suggestions? 

     

    Cheers

  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Try date value function

    Sort( Filter( Times, (IsBlank(DisplayName_3.Selected.Name) || Name = DisplayName_3.Selected.Name) && (IsBlank(Categorycombo1_2.Selected.Categories) || Category = Categorycombo1_2.Selected.Categories) && (IsBlank(OrderNumber1_2.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_2.Selected.OrderDistinct) && (IsBlank(DatePicker2_1.SelectedDate) || Date = DateValue(DatePicker2_1.SelectedDate)) ), Date, SortOrder.Descending )

  • R45 Profile Picture
    94 on at

    @Rajkumar_404 

    There are now 0 errors with the code but no data is displayed when I select a date. Surely there must be a way to filter a SQL data source with that format? I tried to implement the initial code in the last code you suggested.  

     

    Sort(
    Filter(
    Times,
    (IsBlank(DisplayName_3.Selected.Name) || Name = DisplayName_3.Selected.Name) && (IsBlank(Categorycombo1_2.Selected.Categories) || Category = Categorycombo1_2.Selected.Categories) && (IsBlank(OrderNumber1_2.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_2.Selected.OrderDistinct) && (IsBlank(DatePicker2_1.SelectedDate) || Date = DateValue(DatePicker2_1.SelectedDate, "[$-en-US]yyyy-mm-dd"))
    ),
    Date,
    SortOrder.Descending
    )

     

     

  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    It looks like the issue might be with the DateValue function. SQL Server may have different date formats, and it's possible that the date format in the database is not matching the date format that Power Apps expects.

  • R45 Profile Picture
    94 on at

    @Rajkumar_404 

     

    Yes, this was what I assumed thanks. If anybody knows a workaround that doesn't involve changing the SQL data type to varchar that'd be great. That just causes issues with sorting the column.

     

    Cheers

  • Verified answer
    timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @R45 

    What's the datatype of your date column? Is it's datetime rather than date, you might not get the expected rows if the target rows include a time element.

    Also, the datetimeoffset data type is the preferred data type for use with Power Apps. There are some details in this post here.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-Date-from-SQL-DB-not-working/m-p/812333

     

  • R45 Profile Picture
    94 on at

    Hi @timl 

     

    The SQL datatype I had was just date. I have since changed this to datetime offset and my code still does not yield a display on the table. I have opted for a slider to show only data within the last "Slider1.Value" days.

     

    If(
    IsBlank(Slider1.Value),
    Sort(
    Times,
    Date,
    SortOrder.Descending
    ),
    Sort(
    Filter(
    Times,
    Date >= Today() - Slider1.Value
    ),
    Date,
    SortOrder.Descending
    )
    )

     I am just trying to filter by date first before I add in the other filters. Any suggestions?

     

    Cheers

  • timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @R45 

    I would attempt to call the DataAdd function to subtract the days. Does that make a difference?

    If(
    IsBlank(Slider1.Value),
    Sort(
    Times,
    Date,
    SortOrder.Descending
    ),
    Sort(
    Filter(
    Times,
    Date >= DateAdd(Today(), -1 * Slider1.Value, TimeUnit.Days)
    ),
    Date,
    SortOrder.Descending
    )
    )
  • R45 Profile Picture
    94 on at

    @timl 

     

    If(
    !IsBlank(DisplayName_2.Selected.Name) ||
    !IsBlank(Categorycombo1_1.Selected.Categories) ||
    !IsBlank(OrderNumber1_1.Selected.OrderDistinct) ||
    !IsBlank(Slider1_1.Value),
    Sort(
    Filter(
    Times,
    (IsBlank(DisplayName_2.Selected.Name) || Name = DisplayName_2.Selected.Name) &&
    (IsBlank(Categorycombo1_1.Selected.Categories) || Category = Categorycombo1_1.Selected.Categories) &&
    (IsBlank(OrderNumber1_1.Selected.OrderDistinct) || 'Order No.' = OrderNumber1_1.Selected.OrderDistinct) &&
    (IsBlank(Slider1_1.Value) || Date >= Now() - Slider1_1.Value )
    ),
    Date,
    SortOrder.Descending
    ),
    Sort(
    Times,
    Date,
    SortOrder.Descending
    )
    )

     

    I managed to get it working in the above code where I use the date now function. Thanks for your help as I needed datetimeoffset data type.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard