Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to navigate the help pages associated with this, and I simply cannot find this simple reference. I want to show the first ten characters from a DateTime (CloseDate on Opportunity):


I just want the "2012-11-15" reference pulled out. What am I missing here? :-( Thanks for any help, all.

share|improve this question

1 Answer 1

up vote 2 down vote accepted
String myDate = o.CloseDate.year() + '-' + o.CloseDate.month() + '-' +;


String myDate = String.valueOf(o.CloseDate).SubString(0,10);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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