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 Gallery on SQL ...
Power Apps
Unanswered

Filter Gallery on SQL DateTime Field

(0) ShareShare
ReportReport
Posted on by 2

Hi,

 

We are creating an app that is connected to an SQL table to look at operator clock in times. The front page allows the user to select a list of operators, on select, it sets a variable and moves to another page that details all the clock in data for that operator (by filtering using the variable).

 

I want to filter the clock in data based on a date picker: ClockInDatePicker (to only show clock in data for the selected operator on that date), if the date picker is blank, it should show the last 7 x days of clock in data. The clock in date field in SQL is datetime and an example field is: "2023-06-20 07:57:16.307"

 

I have tried various filters on the gallery, but as soon as there is a filter on date, no records are returned.

 

The filter on the Items property on gallery I have tried is:

 

If(
 IsBlank(ClockInDatePicker.SelectedDate),
 Filter('[dbo].[ClockingLog]', OperatorCode = OperatorVar),
 Filter(
 '[dbo].[ClockingLog]', 
 OperatorCode = OperatorVar, 
 Text(ClockedInTime, "[$-en-GB]dd-mm-yyyy") = Text(ClockInDatePicker.SelectedDate, "[$-en-GB]dd-mm-yyyy")
 )
)

 

If(
 IsBlank(ClockInDatePicker.SelectedDate),
 Filter('[dbo].[ClockingLog]', OperatorCode = OperatorVar),
 Filter(
 '[dbo].[ClockingLog]', 
 OperatorCode = OperatorVar, 
 Year(ClockedInTime) = Year(ClockInDatePicker.SelectedDate),
 Month(ClockedInTime) = Month(ClockInDatePicker.SelectedDate),
 Day(ClockedInTime) = Day(ClockInDatePicker.SelectedDate)
 )
)

 

Can anybody help with this?

 

Many thanks!

Categories:
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @CS1986 ,

     

    Try this:

    Filter( '[dbo].[ClockingLog]', OperatorCode = OperatorVar,
    	If(IsBlank(ClockInDatePicker.SelectedDate),
    		ClockedInTime >= DateAdd(Today(),-7,TimeUnit.Days),
    		And(ClockedInTime >= ClockInDatePicker.SelectedDate,
    		 ClockedInTime < DateAdd(ClockInDatePicker.SelectedDate,1,TimeUnit.Days)
    	 )
     )
    )

     

  • CS1986 Profile Picture
    2 on at

    Hi @cha_cha  - many thanks for your help, but as soon as I put that, no records are returned.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard