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

Date Format Compile Errors
Here's the thing:
Trying to insert record with some apex-ifty code.
Schema says field is date type.
SOQL Dumper spits out 2004-04-05 format
I attempt to insert field_name__c='2004-04-05' in Apex Code
I fail.
Error: Compile Error: Invalid initial expression type for field field_name__c, expecting: Date at line #
Why?
Read Cookbook, Getting started, and forum pages.
Trying to insert record with some apex-ifty code.
Schema says field is date type.
SOQL Dumper spits out 2004-04-05 format
I attempt to insert field_name__c='2004-04-05' in Apex Code
I fail.
Error: Compile Error: Invalid initial expression type for field field_name__c, expecting: Date at line #
Why?
Read Cookbook, Getting started, and forum pages.
Simply removing the quotes does not work. It then throws this error:
Compile Error: unexpected token: '2004-04-05' at line 0 column -1
This is what I have in the assignment line:
It worked for me to put in a variable instead of a literal.
Outside of an SOQL statement, you use Date.newInstance. For example:
Inside SOQL, do not use quotes: