function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cnewmancnewman 

Updating a custom date field with the date from another custom field

Hi All,

So we have a booked training date, I'm using a button to set this as cancelled or postponed which puts the date currently in the "Booked Training Date" into another field (Original training date), however when I try and use the date from my Training_Session__c.Booked_Training_Date__c I receive an error message saying the format is not correct for the date type:

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:''0.000868917576961271' is not a valid value for the type xsd:date', }


I've also put in an alert to see what my date field is outputting, as you can see above it's '0.000868917576961271' ... WHY?!?!

This is driving me round the bend, I just want to update one custom date field with the date from another field. do I need to convert it or format it?

Hopefully someone can help :)

Thanks
Chris
Ramu_SFDCRamu_SFDC
The below documentation explains about all the datetime formats that can be used in apex/visualforce.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm

You can also find the date format of any of the date fields and store it in string variable, this way you can identify which format the system accepts

Eg : String closeddate= <field>.format();

Hope this helps !!