Take the 2-minute tour ×
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):

o.CloseDate.SubString(0,10)

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

share|improve this question
add comment

1 Answer

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

Or:

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

Your Answer

 
discard

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.