-2
Custom_Object__c co = new Custom_Object__c(Name='TEST', Date_of_Visit__c=2019-06-06);
insert co;

closed as unclear what you're asking by Pranay Jaiswal, glls, battery.cord, Jayant Das, Vijay Ganji Jun 10 at 6:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You will need to provide exact code and field details here. If this is what you have then there are quite a few issues here. Your custom object should always end with '__c' and then the way you are populating the date is not correct either, assuming that it’s a date field. – Jayant Das Jun 6 at 23:20
4

You haven't provided much in the way of details here, but I'd suspect that your issue is with the date you're trying to set to Date_of_Visit__c

I know that SOQL queries can handle date literals, but I don't think that the rest of Apex at large can.

You should create an instance of the Date class using something like Date.valueOf(), and set your Date field equal to that instead.

  • 1
    Also seems the custom object name here is an issue. At least with the level of information provided. – Jayant Das Jun 6 at 23:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.