+ Start a Discussion
RiyajRiyaj 

Solve the Error : Illegal assignment from String to Datetime

string studentname='0039000000CYPcOAAX';

string classname='a0390000002vWW9AAM';
Datetime dtAttendan='2012-05-22 12:00:00 AM';
InsertOneDateAttendance(studentname,classname,dtAttendan);
attendance__c i = new Attendance__c(student_Name__c= studentname,class_Name__c= classname,attendance_Date__c=dtAttendan);
Insert i;

 

Error: line 3, column 1: Illegal assignment from String to Datetime


AmitSahuAmitSahu

What is the datetime format you are currently using ?

 

You can use this as reference :

 

Datetime dt = DateTime.parse('05/22/2012 11:46 AM');

RiyajRiyaj

Thanks the before error was cleared..but newly one error displayed.. 

 

i m follwed the C#.Net return' date format.

 

 

 

string studentname='0039000000CYPcOAAX';
string classname='a0390000002vWW9AAM';
Datetime dtAttendan = DateTime.parse('05/22/2012 11:46 AM');
InsertOneDateAttendance(studentname,classname,dtAttendan);
attendance__c i = new Attendance__c(student_Name__c= studentname,class_Name__c= classname,attendance_Date__c=dtAttendan);
Insert i;

 

Error:

 

line 4, column 1: Method does not exist or incorrect signature: InsertOneDateAttendance(String, String, Datetime)

 

APEX Class

 

global class InsertOneAttendanceDate{
WebService static void InsertOneDateAttendance(string studentname,string classname,datetime dtattendance){
Attendance__c i=new Attendance__c(student_Name__c= studentname,class_Name__c= classname,attendance_Date__c= dtattendance);
Insert i;
}
}



AmitSahuAmitSahu

Probably you have to instanciate the method: InsertOneDateAttendance

 

InsertOneAttendanceDate.InsertOneDateAttendance(parameters);