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
kiran raju 19kiran raju 19 

Merge two custom date fields

Hi all,
I want to merge the two date fileds in opportunity module. In have record type for opportunity object in that in want to merge the Shippment date and delivery date as one filed.

Can anyone help me over here.

Thanks in advance,
raju
SandhyaSandhya (Salesforce Developers) 
Hi,

You can create a formula field that will display the concatenated value.
The formula field would be of type text and would have formula similar to
FieldName1+ ‘ ‘ +FieldName2


Best Regards,
Sandhya
kiran raju 19kiran raju 19
Hi Sandya,

Thanks for the replay, is there any other way with out using formula field.
Raj VakatiRaj Vakati
You can use apex like below 
 
Date date1 = System.today();
Date date2 = System.today().addMonths(30);
Date d2 = date1.addDays(date2.day()) ;
d2.addMonths(date2.month()) ; 
d2.addYears(date2.year()) ; 

System.debug('d2'+d2);

 
Deepali KulshresthaDeepali Kulshrestha
Hi Kiran,
As far as I understand your question you need a custom field that has concatnated value of Shippment date and delivery date. One thing you can do is you can create a custom field and a Apex class. In Apex class query both the fields and store it in seperate lists. Now run a for each loop on both the lists and do following:
1. //Create opportunity instance 
2. Now in a temp string variable store "String.parse(instance.shippingDate) + String.parse(instance.deliveryDate)".
And this should do the job.

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

Thanks and Regards,
Deepali Kulshrestha