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
LavanyaLavanya 

Error: Compile Error: Illegal assignment from String to Date

Hi this the error i am getting

Error: Compile Error: Illegal assignment from String to Date at line 95 column 1.

 

In the code  i had make that error line bold.

code:

for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');

Opportunity opp = new Opportunity();
opp.Name = inputvalues[3];
opp.OPP_DateOfBirth__c = inputvalues[4];
opp.StageName = inputvalues[6];
opp.CloseDate = inputvalues[5];

opptoupload.add(opp);
}

 

neeedhelpneeedhelp

Instead of this opp.OPP_DateOfBirth__c = inputvalues[4];

try using this opp.

opp.CloseDate = date.ValueOf(inputvalues[5]);

 

LavanyaLavanya

Hi thanks for the reply, u tried this but i am getting VF error.

 

neeedhelpneeedhelp
try this once
opp.closedate = date.parse(inputvalues[5]);
and can use check what values are coming into inputvalues[5]
Jerun JoseJerun Jose
Could you debug inputvalues[5] to display the value that is being passed.
Unless a proper date data is received it cannot be assigned to a date field.