+ Start a Discussion
Shree KShree K 

How to get two DateTime fields result in the form of no of dd-mm-yyyy in another field?

I have two fields on my Object ,as date time (data type) like Start_date__c and End_date,if i enter the 1-1-2014 in start date and 7-7-2015 in end date fields,the results suppose be like 1Y-6M-5D (i.e 1 year 6months 5 days) not exactly the same format as i mentioned but,my requirement is like users should be able to know how many years,moths,weeks and days left in another field, counting from the date that user enters in the fields.  
Wondering if this is possible with configuration or do i need apex?
NagaNaga (Salesforce Developers) 
Hi CkRdY,

1. You can change the format by just doing DATEVALUE(CreatedDate) in your custom formula field. That will render it as a date instead of datetime.

2. Do you always want dd/mm/yyyy? Or do you want it to reflect the standards of each region? You can change the "Locale" field on the User to get this to happen. If you insist on dd/mm/yy, then you will need to have a formula field that is a text field and do this:


If you do that, however, your field must be type text and then you lose some functionality, i.e. you can't compare it to other date fields and such.

Best Regards
Naga kiran
This this in a text formula field:

YEAR(Date2__c ) - YEAR(Date1__c)&"Y-"&
MONTH(Date2__c ) - MONTH(Date1__c) &"M-"& (((Day(Date2__c) - Day(Date1__c)))/30)&"D"