I have my date in following format:
2014-01-20 00:00:00
I want it in the following format
1/20/2014(mm/dd/yyyy)
But i want it as date variable not as a string.
[SalesForce] How to convert the following date format in salesforce
Related Topic
- [SalesForce] How to format today’s date in this format
- [SalesForce] Need to convert date format in apex
- [SalesForce] How to convert Date to format “YYYY-MM-DDThh:mm:ss-hh:mm”
- [SalesForce] Format specific date in Apex as dd/mm/yyyy – illegal assignment from string to date
- [SalesForce] Date format validation
Best Answer
You already have a date 'as a date', not as a string. The format you are talking about (2014-01-20 00:00:00) is just a visual representation of a value contained in variable of a DateTime type. If you want the date to appear in the specified format (1/20/2014), just output it using format() method: