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 I get my date a...
Power Apps
Answered

How do I get my date and time field to store and display data correctly?

(0) ShareShare
ReportReport
Posted on by 330
I have a Datacard on my form which is a SharePoint date/time column (Date & time format). The default property on the datacard is
ThisItem.'MyDateTimeColumn'
With update property of the datacard as...
Now()
The user experience I am trying to achieve is...I have a drop down on the form. When a user (an approver) selects their decision from a drop down (Approve, Reject), the date and time is set as a timestamp. To try to achieve this, in the OnChange of my drop down, I have
MyColumn_DateValue.SelectedDate = Now();
MyColumn_HourValue.Selected.Value = Text(Hour(Now()));
MyColumn_MinuteValue.Selected.Value = Text(Minute(Now()));
 
And in the OnSelect of the button I am using to submit the form, I am using this patch statement to save the data to the SharePoint list...
Patch(
 'MySharePointList'
 LookUp('MySharePointList', ID=ThisItem.ID)'
 {
  'MyDateTimeColumn': DateAdd(
    Day(MyColumn_DateValue.SelectedDate),
    Hour(MyColumn_HourValue.Selected.Value) + Minute(MyColumn_MinuteValue.Selected.Value)
 }

)
 
Here are my observations
- when the form is open (before the drop down value is selected), there is already a date and time value displayed on the field. This should remain empty until the user makes a decision by selecting an option from the drop down.
- when the patch is executed, I see weird values being saved in the SharePoint list like 12/31/1969 7:00PM when the actual data should have been 1/15/2026 10:00AM
 
 
How do I go about making this work in the desired way? Many thanks 
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Firstly try this structure - OnChange of your drop-down
    UpdateContext({varDateTime: Now()})
    Now the DefaultDate of your Date Picker
    Coalesce(
       varDateTime,
       ThisItem.'MyDateTimeColumn'
    )
    The Default of your Hour drop-down
    Text(
       If(
          !IsBlank(varDateTime),
          Hour(varDateTime),
          Hour(ThisItem.'MyDateTimeColumn')
       ),
       "00"
    )
    and the Default of your Minute drop-down
    Text(
       If(
          !IsBlank(varDateTime),
          Minute(varDateTime),
          Minute(ThisItem.'MyDateTimeColumn')
       ),
       "00"
    )
    and your Patch
    Patch(
       'MySharePointList',
       {
          ID: ThisItem.ID,
          'MyDateTimeColumn': 
          MyColumn_DateValue.SelectedDate + 
          Time(
             Value(MyColumn_HourValue.Selected.Value),
             Value(MyColumn_MinuteValue.Selected.Value),
             0
          )
       }
    );
    UpdateContext({varDateTime: Blank()})
    Also initiate the Variable at Screen OnVisible
    UpdateContext({varDateTime: Blank()})
     
    Please ✅ 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Spawn10 Profile Picture
    330 on at
    @  Thanks a million for this as it definitely has my going in the right direction. The only issue i am now running into, is that this is not recording the accurate time. For instance it gives me a timestamp of Saturday January 17th, with the incorrect time...while today is still Friday January 16th. 
    I can't tell why. 

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard