You need to sign in to do that
Don't have an account?

How to split dates
hi,
I want to split dates according to monthsBetween() start date and end date and I'm confused so if any one has any of the solutions... than plz ... tell me... thanks in advance.... :)
hi u can use the following snippet for ur requirement
Date a = Date.newInstance(2013,10,7);
Date b = Date.newInstance(2014,1,12);
Integer monthDiff = a.monthsBetween(b);
if (b.day() > a.day()) monthDiff++;
System.debug(monthDiff);
hello.... thanks.. for recognition ... :)
can i do this dynamically ... opportunityLineItem.StartDate__c
...???
Date a = Date.newInstance(opportunityLineItem.StartDate__c );
Hi,
If the opportunityLineItem.StartDate__c field is already in Date field type you don't need to create a new instance. You can calculcate the months by doing this
Integer diff = opportunityLineItem.StartDate__c.monthsBetween(opportunityLineItem.EndDate__c);
But I'm not sure what you exactly mean by splittin the dates ?
hi,
Yes ....... I want to split dates ... as in , i'm creating records based on the difference of months comes in oli's start date and end date like.. if the difference is 4 then 4 child records will be created ... nd now the problem is i want to create new dates to newly created records ...accordingly... so plz tell me that how to calculate new dates...from original... dates of parent record....
thanks...
Hi...You can try this if meets your requirements.