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
Anu Raj.ax1269Anu Raj.ax1269 

Date format

Hi 

I am getting date as 2012-07-03 00:00:00 but I want the date format as 03/07/2012 is it possible to get it this way without time 

please help me to solve this problem thanks.

 

thanks 

Anu

Best Answer chosen by Admin (Salesforce Developers) 
PrakashbPrakashb

Hi Anu,

 

the date you are using might be a date field. Convert that to a datetime field and then use the format option.

All Answers

PrakashbPrakashb

Hi Anu,

 

After getting the date you can use the format method to convert it to a different format.

 

Anu Raj.ax1269Anu Raj.ax1269

yes i have used it 

string dateformat = strConvertedDate.format('dd/mm/yyyy');

 

and i am getting this error :


Error: Compile Error: Method does not exist or incorrect signature: [Date].format(String)
PrakashbPrakashb

Hi Anu,

 

the date you are using might be a date field. Convert that to a datetime field and then use the format option.

This was selected as the best answer
Anu Raj.ax1269Anu Raj.ax1269

thanks i did the same think it worked.