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
abhilash reddy 30abhilash reddy 30 

how to divide number of hours b/w months of start date and end date?

I am New to Salesforce,I don't Know How to Complete Below Trigger Scenario...PLZ help me to Complete below scenario...i will be highly oweful to you..


My Trigger Scenario:I have a object called "Project" having below Fields.
       ---->Project Name
       ---->Project Start Date
       ---->Project End Date
       ---->Total NO.of Hours( default value 100 hours )
       ---->Project Ratio(Picklist Data Type) having below values(Interms of Hours)
                --> 100-1
                --> 70-30    
                --> 50-50
                --> 30-70
                --> 0-100
Requirement:
------------
   If user selects Project Start Date And Project End Date,For Example User Select 2-3-2017 as Project Start Date and 20-9-2017 as Project End Date  and
       -->if user select "100-1" from picklist,total 100 hours(before Hyphen value) should be alloted to Project Start Date i.e "March" in this case.
       -->if user select "70-30" from picklist, 70 hours(before Hyphen value) should be alloted to Project Start Date i.e "March" in this case, remaining 30 Hours(after Hyphen Value) should be alloted to remaining months(In my case April,may,june,july,August,sep),we have to consider number of days in each month as well.
       -->if user select "50-50" from picklist, 50 hours(before Hyphen value) should be alloted to Project Start Date i.e "March" in this case, remaining 50 Hours(after Hyphen Value) should be alloted to remaining months(In my case April,may,june,july,August,sep),we have to consider number of days in each month as well.
       -->if user select "30-70" from picklist, 30 hours(before Hyphen value) should be alloted to Project Start Date i.e "March" in this case, remaining 70 Hours(after Hyphen Value) should be alloted to remaining months(In my case April,may,june,july,August,sep),we have to consider number of days in each month as well.
       -->if user select "0-100" from picklist,total 100 hours(After Hyphen value) should be alloted to Project End Date i.e "March" in this case.
After Completion of Above Requirement every Project Record should have a related list with below records:
       -->In Case Of "100-1" pick list Selection
           Record 1:March-100
           Record 2:April-0
           Record 3:May-0
           Record 4:June-0
           Record 5:July-0
           Record 6:AUgust-0
           Record 7:September-0

       -->In Case Of "30-70" pick list Selection
           Record 1:March-30
           For Remaining six records,70 hours should be devided to remaining Months ,we have to consider number of days in each month as well.
 
--------->Continue the above process for Remaing Pick List Selecton values As well.
please help me on this.........
Narayanan NatarajanNarayanan Natarajan

Hai Mr.Abhilash,


       Its easy way to do. As of my knowledge, 
      Case 1 : 70 - 30 
         March has 70 hours. Remaining 30 hours had to be splitted to 6 Months.. i.e:) 30 / 6 = One Month occurs 5 hours to do..

      Case 2 : 30 - 70
    
         March has same 30 hours. Remaining 70 hours to be splitted into 6 Months.. i.e:) 70 / 6 = 11 (Provide 11 hours for 6 months). We had remaining 4 hours. Is it? Then Covert that 4 Hours into Minutes (4 * 60 = 240). Then distribute that minutes to remaining 6 Months. Now Each of 6 Months takes 11 hours 40 Minutes.

      Case 3 : 50 - 50

        March has 50 hours. Remaining 50 / 6 = 8 (8 hours splitted to 6 Months)...  We have remaining 2 hours. Covert (2 * 60 = 120). Split 120 Minutes to 6 Months. Then Each of 6 months holds 8 hours with 20 Minutes.
 
NOTE : Please do conversion upto milliseconds whenever we cant...
Thanks & Regards, 
Narayanan Natarajan

abhilash reddy 30abhilash reddy 30
Thank you Narayanan for ur kind Reply...that is ok but we have to consider number of days in month as well accordingly we have to divide