Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Unanswered

Wrong date saved in SharePoint via a PowerApps application

Like (1) ShareShare
ReportReport
Posted on 3 Oct 2024 19:01:15 by 6
Hello,
 
I have an PowerApps link to an SharePoint List. My SharePoint list have these columns:
 
Column Type
Title Single line of text
StartDate Date Time
EndDate Date Time
Date Date Time
 
In my powerapps, i have an interface and One button submit. When user select submit button the data is saved in SharePointList.
 
This is the source code of Submit Button.
 
Set(StardDate, DateAdd(Date(2024-10-14), 720, TimeUnit.Minutes))
Set(EndDate, DateAdd(Date(2024-10-14), 1020, TimeUnit.Minutes))
Set(Date,Date(2024-10-14)))
 
Patch(SharePointList, Defaults(SharePointList),
{
    Title:"Test",
    StartDate: StartDate,
    EndDate:EndDate,
    Date:Date
})
 
 
The problem i have now is this.
 
When the data is saved in sharePoint List, this is how the appear (see table bellow and attachment)
Column Value
Title Test
StartDate 2024-10-14 09:00
EndDate 2024-10-14 14:00
Date 2024-10-13 20:00
 
The column Date have a wrong value 2024-10-13 20:00. Note that this appear only for few nomber of user.
All the user have a same time zone on her computer and her office 365 profile.
 
SharePoint Time zone is the same for all the users.
 
What can explain this time difference for the Date field?
 
Please can you help me?
 
Thanks a lot in advance.
 
 
  • CU03101748-0 Profile Picture
    CU03101748-0 6 on 07 Oct 2024 at 13:02:42
    Wrong date saved in SharePoint via a PowerApps application
    Thanks for your help,
    Ibendlin: Yes the users have UTC-4
    Ekarim: i understand what do you explain. All the users is on the same Time Zone in their computer and their office 365 profile.
     
    The thing i don't understand is why the problem occur only for one date field if it id the time zone the problem? Normaly if it this the time zone the problem all the date fields must be affected?
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,316 on 04 Oct 2024 at 21:09:02
    Wrong date saved in SharePoint via a PowerApps application
    I am in a different time zone to you, so am just getting back to this (Saturday Morning 7am here). You had already confirmed that the SharePoint time zone was the same (it always is), but it appears that the user/s concerned may have their device Regional Settings four hours behind the SharePoint site. If Date is a date-only field (not date/time), you can do this (or set it at the maximum difference)
    With(
       {
          _Start: DateAdd(Date(2024,10,14), 720, TimeUnit.Minutes),
          _End: DateAdd(Date(2024,10,14), 1020, TimeUnit.Minutes),
          _Date: DateAdd(Date(2024,10,14), 4, TimeUnit.Hours)
       },
       Patch(
          SharePointList,
          Defaults(SharePointList),
          {
             Title: "Test",
             StartDate: _Start,
             EndDate: _End,
             Date: _Date
          }
       )
    )
    The other way is to fix the user's settings, but they may be correct for their location.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • lbendlin Profile Picture
    lbendlin 7,906 on 04 Oct 2024 at 14:00:59
    Wrong date saved in SharePoint via a PowerApps application
    Are your users all on UTC-4 ?
  • EKarim Profile Picture
    EKarim 10,445 on 04 Oct 2024 at 14:00:42
    Wrong date saved in SharePoint via a PowerApps application
    As far as I understand:
    • SharePoint stores dates in UTC (Coordinated Universal Time) time zone regardless of the user's or site's time zone settings.
       
    • When you view dates dates in SharePoint, they are displayed according to the site's Regional settings.
       
    • When Power Apps retrieves dates from SharePoint it will be in UTC, displayed based on your PCs Time Zone settings.
       
    • Power Automate reads dates from SharePoint as UTC.

    Example:

    Windows PC Time Zone: UTC-08:00 Pacific Time (US & Canada)
    Windows 11 Region Format (for displaying Date Time): English (United Kingdom)

    SharePoint Item has a Created date:    "2024-10-05T08:15:34Z"
    Power Automate reads the Created date: "2024-10-05T08:15:34Z"


    Power Apps Code displays the date and time:
    (1) "Created: " & ThisItem.Created "05/10/2024 01:15" 
    (2) "Created: " & Text(ThisItem.Created, DateTimeFormat.UTC) "2024-10-05T08:15:34.000Z"


    In (1) above, Power Apps automatically converted the UTC timestamp to my local time zone which is UTC-08:00 Pacific Time (US & Canada). In (2) the Text function is used to format the date and time to UTC .
  • CU03101748-0 Profile Picture
    CU03101748-0 6 on 04 Oct 2024 at 12:27:30
    Wrong date saved in SharePoint via a PowerApps application
    hello Warrenbelz, Thanks you for your help. I try your code but i have the same problem for many user.
     
    The issue is perssist.
  • WarrenBelz Profile Picture
    WarrenBelz 144,316 on 03 Oct 2024 at 22:18:18
    Wrong date saved in SharePoint via a PowerApps application
    Firstly Date is a very bad name for a Variable and I believe your issue may be ambiguity. I have tested this code and it works as expected
    With(
       {
          _Start: DateAdd(Date(2024,10,14), 720, TimeUnit.Minutes),
          _End: DateAdd(Date(2024,10,14), 1020, TimeUnit.Minutes),
          _Date: Date(2024,10,14)
       },
       Patch(
          SharePointList,
          Defaults(SharePointList),
          {
             Title: "Test",
             StartDate: _Start,
             EndDate: _End,
             Date: _Date
          }
       )
    )
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,316

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard
Loading started
Loading complete