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 Pages / Date field formatting
Power Pages
Unanswered

Date field formatting

(0) ShareShare
ReportReport
Posted on by 10

Hi all,

I have put (dd/M/yyyy) datetime/dateformat in sitesettings of power portal.There is a dob date field on service web page ,which is populated from birthday field of contact record using ajax and it is set using
var x=new Date(res.birthday)
$('#dob').val(x.toString('dd/M/yyyy'))
,where res is result from ajax call ,but I am unable to store dob field in dataverse , dob is showing blank while submitting form on service webpage ,there are no console errors on submission.But if I change the date using date picker and submit form ,it is showing in dataverse table.Can anyone please help me with this.

Thank you

Categories:
I have the same question (0)
  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @PPBeginner ,

     

    Please try below snippet:

     

    // Get your date from api call()
     var dateValue = new Date(res.birthday);
     // Get date field
     var dateField = $("#dis_dateofbirth"); //Replace schema name with your column
     dateField.val(moment.utc(dateValue).format("YYYY-MM-DD"));

     

    Feel free to share, if you face any issues.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • PPEnthusiast Profile Picture
    10 on at

    Hi @saudali_25 ,

    Thanks for your reply,

    I tried your code but I am getting error and I also want to know why the value set is not showing on the form

     

    SwapnaPriya_0-1690309381008.png

     

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @PPBeginner ,

     

    Please note that, CRM will accept dates in the format that you've set for column. The error shows the format you're passing to set date is not what you've in CRM. I posted example according to the format that I have. Please change the date format before setting it and it should work.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    As per your other post, set the date value on the datepicker object (not what you think is the field)

    // set a default date to a specific date
    $("#your_fieldname") // input control
     .next() // the date picker container
     .data("DateTimePicker") // the date picker object
     .defaultDate(new Date("2020-01-01"));

     

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 Pages

#1
rezarizvii Profile Picture

rezarizvii 55

#2
11manish Profile Picture

11manish 48

#3
Valantis Profile Picture

Valantis 46

Last 30 days Overall leaderboard