This error generally arise when you are assigning datetime field value to Date.
Example :
Assume submitted_Date__c is a date field created on Account.
Account acc = new Account();
DateTime dt = system.Now();
acc.submitted_Date__c = dt;// This line gives error as dt is a datetime field assigning to Date field(submitted_Date__c)
Solution:Convert DateTime to Date and then assign it to other date field.
use date() to convert DateTime to date.
Account acc = new Account();
DateTime dt = system.Now();
acc.submitted_Date__c = dt.date();
Example :
Assume submitted_Date__c is a date field created on Account.
Account acc = new Account();
DateTime dt = system.Now();
acc.submitted_Date__c = dt;// This line gives error as dt is a datetime field assigning to Date field(submitted_Date__c)
Solution:Convert DateTime to Date and then assign it to other date field.
use date() to convert DateTime to date.
Account acc = new Account();
DateTime dt = system.Now();
acc.submitted_Date__c = dt.date();
No comments:
Post a Comment