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 / DateTime Timezone Issu...
Power Apps
Answered

DateTime Timezone Issue When Calculating Weekdays-Only or Populating DateTime Value in Canvas App Published Mode

(0) ShareShare
ReportReport
Posted on by 473

This issue is regarding a DateTime issue where a Date, after it is calculated to only contains weekdays, is mismatched by 1 day when the Date is populated to a created record in Published Mode.

1. Store WeekdayDates and PublicHolidayDates between ToDate_Dp and FromDate_Dp

 

With(
 {
 // Generate a one-column table of all dates between start date & end date
 varDateRange: ForAll(
 Sequence(ToDate_Dp.Value - FromDate_Dp.Value + 1),
 FromDate_Dp.Value + Value - 1
 )
 },

 //Store Weekday Dates
 ClearCollect(
 WeekdayDates,
 Filter(
 varDateRange,
 Weekday(Value) in [ 2, 3, 4, 5, 6 ]
 )
 );

 //Store Public Holiday Dates
 ClearCollect(
 PublicHolidayDates,
 Filter(
 varDateRange,
 Value in Filter( 'Public Holidays', 'Public Holidays (Views)'.'Active Public Holidays' ).Date
 )
 );
 );

 

- Taking these dates as example:
- 01 Sep 2024 to 08 Sep 2024 (Sun to Sun)
- 04 Sep 2024 (Wed) as dummy Public Holiday.

gymcode_0-1706463789125.pnggymcode_1-1706463831909.png

*Following incorrect behaviours only occurs in Published Mode*


1. Patch() records where _Date Not In PublicHolidayDates (Correct results)

 

Patch(
 'Reservation Details',
 ForAll(
 Sequence(
 DateDiff( FromDate_Dp.Value, ToDate_Dp.Value, TimeUnit.Days ) + 1
 ),
 With(
 {
 _Date: DateAdd( FromDate_Dp.Value, Value - 1, TimeUnit.Days )
 },
 
 If(
 Not(_Date in PublicHolidayDates),
 {
 Date: _Date
 }
 );
 )
 )
);

 

 1-Sep - Sun2-Sep -Mon3-Sep - Tue4-Sep - Wed5-Sep - Thu6-Sep - Fri7-Sep - Sat8-Sep - Sun
Expected
( Created? )
YesYesYesNoYesYesYesYes
Results 
( Created? )
YesYesYesNoYesYesYesYes



2. Patch() records where _Date in WeekdaysDates (Incorrect results)

 

Patch(
 'Reservation Details',
 ForAll(
 Sequence(
 DateDiff( FromDate_Dp.Value, ToDate_Dp.Value, TimeUnit.Days ) + 1
 ),
 With(
 {
 _Date: DateAdd( FromDate_Dp.Value, Value - 1, TimeUnit.Days )
 },
 
 If(
 (_Date in WeekdayDates),
 {
 Date: _Date
 }
 );
 )
 )
);

 

 1-Sep - Sun2-Sep -Mon3-Sep - Tue4-Sep - Wed5-Sep - Thu6-Sep - Fri7-Sep - Sat8-Sep - Sun
Expected
( Created? )
NoYesYesYesYesYesNoNo
Results
( Created? )
NoNoYesYesYesYesYesNo



3. Patch() records where _Date Not In PublicHolidayDates and _Date in WeekdaysDates (Incorrect results)

 

Patch(
 'Reservation Details',
 ForAll(
 Sequence(
 DateDiff( FromDate_Dp.Value, ToDate_Dp.Value, TimeUnit.Days ) + 1
 ),
 With(
 {
 _Date: DateAdd( FromDate_Dp.Value, Value - 1, TimeUnit.Days )
 },
 
 If(
 ((_Date in WeekdayDates) && Not(_Date in PublicHolidayDates)),
 {
 Date: _Date
 }
 );
 )
 )
);

 

 1-Sep - Sun2-Sep -Mon3-Sep - Tue4-Sep - Wed5-Sep - Thu6-Sep - Fri7-Sep - Sat8-Sep - Sun
Expected
( Created? )
NoYesYesNoYesYesNoNo
Results
( Created? )
NoNoYesNoYesYesYesNo

 

I have tested more scenarios, but to keep my question simple, the above 3 scenarios best describe the issue.

Current analysis and findings:

1. Dates populated by WeekdaysDates calculation is 1 day off during Patch()

2. Dates populated by PublicHolidayDates calculation is not affected

3. Issue only occur in Published Mode. In Editing Mode, the results are correct in all scenarios.

I have the same question (0)
  • Verified answer
    ivan_apps Profile Picture
    2,189 Moderator on at

    Date calculation issues beg the question - did you consider the timezone stored in you date field?

     

    often a +/- 1 day difference tends to come from a date stored with UTC time and the calculation done with local time zone. 

     

    Are you storing your date fields as 'date only' with the time zone adjustment set to 'Date Only' or 'Time zone independent'? I'm guessing since you are doing holiday calculations, you don't need the time, so 'Date Only' makes sense to me.  Take a look at how you've configured your date fields and you may have your answer there.  Unfortunately you can't really change the Time Zone Adjustment once you've set it, so you may have to recreate the field.

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard