web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / OpenForm with Date Onl...
Power Apps
Answered

OpenForm with Date Only parameter values off by one day (Model-driven)

(0) ShareShare
ReportReport
Posted on by 311

In my model-driven app, I'm opening a form from javascript using Xrm.Navigation.openForm with parameters to auto populate some fields.  One of the fields is of type Date Only, with behavior set to "Date Only".  I'm assigning the parameter value with a string formatted as "yyyy-MM-dd".  When the form opens, the value is off by one day.  For example, if it assign the parameter the value "2021-09-02", the form opens with the field value of "9/1/2021".

 

This seems like a bug to me.  Anyone know of a fix other than adding code in the OnFormLoad event to add 1 day to each Date Only value?

I have the same question (0)
  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @tschopp , 

     

    I suppose that the problem is about the user time. When you use in javascript, the Date() it will be automatically converted to user time.

    When I make a new Date for 2nd Aug 2021, I get 2021-09-01T22:00:00Z (in my case Central European Sommer Time)

    DianaBirkelbach_0-1630833761681.png

    The "DateOnly" wil be considered on the server side, when saving, but I guess this date is parsed in javascript.

     

    One way would be to pass the date including the hour:

     

    new Date(2021, 8, 2).toISOString()

     

    If this doesn't work, as a cheap workaround, I suggest passing the date for 12 a clock. That should be the same day for all time zones.

     

    new Date(2021, 8, 2, 12).toISOString()

     

     

    Hope this helps!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 428

#2
WarrenBelz Profile Picture

WarrenBelz 374 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard