You need to sign in to do that
Don't have an account?

Date value in test method?
Hi,
I have a date field mandatory in a custom object, when writting the test method i get an error:
Compile Error: Invalid initial expression type for field Start_Date__c
Error: Compile Error: Invalid initial expression type for field Start_Date__c, expecting: Date at line 14 column 44
|
How do I have to set the date??
I have tried:
dd/mm/yyyy
dd/mm/yy
ddmmyy
'Today'
Thank you!
Just do this
cusObj.Start_Date__c = Date.today(); // will set the todays date
If you want to give any particular date
cusObj.Start_Date__c = Date.newInstance(1980 , 10 ,20); //yyyy , mm , dd
All Answers
You can do something like
Datetime currTime = System.now();
corpAction.Action_Date__c = Date.newInstance(currTime.year(), currTime.month(), currTime.day());
Thanks,
-John
Just do this
cusObj.Start_Date__c = Date.today(); // will set the todays date
If you want to give any particular date
cusObj.Start_Date__c = Date.newInstance(1980 , 10 ,20); //yyyy , mm , dd
Thanks!! to both of U!!!
I was using:
' Date.today() '
instead of just
Date.today()