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 / How do you account for...
Power Apps
Unanswered

How do you account for DST in a Filter based on a Date field?

(0) ShareShare
ReportReport
Posted on by 241

I have an entity that contains a Date field. How can I properly filter on it? (pure CDS)

 

Right now, I have something that looks kind of like this:

UpdateContext({ selectedDay: DateAdd( Today(), 7, Days ) });
Set( planning, First( Filter( Projects, Datum=selectedDay ) ) );

 

However, in about 2 weeks DST will kick in (Netherlands) and suddenly the filter doesn't return a value any more.

Categories:
I have the same question (0)
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @MrNappa ,

    Do you want to filter date based on DST?

    Since DST is earlier one hour than standard time, I suggest you firstly transfer local time(DST) to standard time.

    Then compare the transferred time with the field in CDS.

    Try this formula:

    pdateContext({ selectedDay: DateAdd( Today(), 167, Hours ) });
    Set( planning, First( Filter( Projects, Datum=selectedDay ) ) );

    //167=7*24-1   

     DateAdd( Today(), 167, Hours ) means that adds 7 days and minutes 1 hour.

    Local time is earlier 1 hour than standard time, so you need to minutes 1 hour to transfer to standard time.

     

     

    Best regards,

  • MrNappa Profile Picture
    241 on at

    Thanks for the suggestion, @v-yutliu-msft .

    Actually, I used the following workaround for now:

    Set( planning, First( Filter( Projects,
     Datum>=DateAdd(selectedDay, -1, Hours),
     Datum<=DateAdd(selectedDay, 1, Hours) 
    ) ) );

    That would also work when looking ahead in the other direction. However, it doesn't feel like the most robust piece of code. I guess that's just the limitation of having a date field that's internally stored with also a time component

  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @MrNappa ,

    Yes, you are right.

    If you save date and time together,date value will be affected by time value.

    So you need to use DateAdd function to transfer time to avoid the effect.

    Do you have any other problems?

    If not, could you change your issue status to "Answered"?

    Thanks!

     

    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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard