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
john4sfdcjohn4sfdc 

Datetime error

Datetime insdate;
insdate = 2013-10-07 00:00:00;
System.debug(insdate);

 

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.

 

http://boards.developerforce.com/t5/Other-Salesforce-Applications/How-to-Assign-a-DateTime-field-value-to-another-Datetime-field/td-p/97830

 

http://eprasu.wordpress.com/2010/01/25/salesforce-converting-datetime-to-format-yyyy-mm-ddthhmmssz/

 

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

Thanks,
Subhani,
Salesforce Certified Developer,
www.mydbsync.com

 

 

 

 

 

jungleeejungleee

You could instantiate a date something like this:

 

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