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

Datetime error

Datetime insdate;
insdate = 2013-10-07 00:00:00;


when i try to execute this as  annonymous, I get the error unexpected token: '2013-10-07'


My question is, How do we assign a datetime value to a variable?

Subhani PSubhani P

Hi John,


check the following links to answer for your questions.


If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Salesforce Certified Developer,







You could instantiate a date something like this:


datetime insDate =datetime.newInstance(2013, 10, 1,00,00,00);
system.debug('insDate is '+ insDate);