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
Sean GibsonSean Gibson 

Formula Field - changing order of a date/time value converted to a text field

Hi,

I am fairly new to salesforce as an admin, I am looking for a bit of advice around a formula field,

I have a field which converts a date/time value and takes only the date bu converting it to text, however the format of the date is YYYY-MM-DD, I am wondering if there is any way to change the order of the date field so it shows DD-MM-YYYY

My formula is below;

Name&" - "&ProductCode__r.Name&" - "&LEFT(TEXT(Outward_Date__c),FIND(" ",TEXT(Outward_Date__c))-1)&" - "& From__r.Name&" >> "&To__r.Name

Appreciate any help I can be offered,

Thank you,
Best Answer chosen by Sean Gibson
Ajay K DubediAjay K Dubedi
Hi Sean,

I looked at your issue and found the solution. I tested it at my org and it worked.
You have one formula field-
Date field will be in  DD-MM-YYYY format by this solution.

Replace Your code with this->

Name&" - "&ProductCode__r.Name&" - " & Right(TEXT(Outward_Date__c),2) &"-"& RIGHT(LEFT(TEXT(Outward_Date__c),7),2) &"-"& LEFT(TEXT(Outward_Date__c),4) &" - "& From__r.Name&" >> "&To__r.Name


This piece of formula will write the date in DD-MM-YYYY format.

 Right(TEXT(Outward_Date__c),2) &"-"& RIGHT(LEFT(TEXT(Outward_Date__c),7),2) &"-"& LEFT(TEXT(Outward_Date__c),4)


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com