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

How to solve System.TypeException: Invalid date/time issue

Hi i've a custom field called lastmodifiedcom__c  in Task object.

But when i'm trying to set myTaskObj.lastmodifiedcom__c value it gives 
System.TypeException: Invalid date/time error..

This is my code 

   system.debug('TIMEDATE IS'+systemDate);
   myTaskObj.lastmodifiedcom__c =  DateTime.parse(systemDate);

Thank you very much
Abhishek BansalAbhishek Bansal

Why are you not directly using this code :
myTaskObj.lastmodifiedcom__c =;

Please check and let me know if you have any issue.

William TranWilliam Tran
Try adding a space between the date and hour such as

format('yyyy-MM-dd HH:mm:ss')

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.