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
Lukasz PiziakLukasz Piziak 

Formula field based on Date and Date/Time field type

Hi,
I'm looking for formula to get the following logic.

We have 2 felds

Testing Date (date field type)
Testing Date/Time (date/time field type)

We would like to achieve the following formula for text field
If 'Testing Date' is blank use 'Testing Date/Time' 
If these 2 fields are blank use 'N/A'

When 'Testing Date/Time filed value is used it should be in the following format DD/MM/YYYY

Many thanks for help
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Lukasz,

Can you try the below formula.
 
IF(NOT(ISBLANK( DateField__c )) ,TEXT(DAY(DateField__c))+"/" +TEXT(MONTH(DateField__c))+"/" +TEXT(YEAR(DateField__c))

,

IF( NOT(ISBLANK( DateTimeField__c ) ), TEXT(DAY(DATEVALUE(DateTimeField__c)))+"/" +TEXT(MONTH(DATEVALUE(DateTimeField__c)))+"/" +TEXT(YEAR(DATEVALUE(DateTimeField__c)))

,'NA' ) )

Replace DateField__c with your date field and DateTimeField__c with datetime field.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Lukasz PiziakLukasz Piziak
Hi Sai,
Many thanks for help. Formula is working perfectly. Just one think, date format is as follow, e.g today 12/01/2023 formula is showing 12/1/2023.
Is it possible to change to the format to read 12/01/2023?

Thanks