You need to sign in to do that
Don't have an account?
Donald Reagan 3
Assign row values from one object to another object as columns or fields
I have row values as dates in one object, i.e dates within a given year. I have a second object with field names as Day1__c, Day2__c and so on till Day366__c. I want to assign the dates to the fields in the 2nd object.
Example, if the date in the first object is 2018-01-01 I want to assign a value to field Day1__c in the second object and if the date is 2018-12-31 I want to assign a value to Day365__c.
Thanks for any help.
Example, if the date in the first object is 2018-01-01 I want to assign a value to field Day1__c in the second object and if the date is 2018-12-31 I want to assign a value to Day365__c.
Thanks for any help.
Please find the code below.
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Regards,
Kapil
(forcecube@gmail.com)
All Answers
I hope the dayOfYear() method of Date class https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm can help you to achieve this requirement.
As per Salesforce it "Returns the day-of-year component of a Date." First, you have to get this number (suppose 294) based on the Date from the first object and you can relate the corresponding field in the second object as Day241__c. Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra
Please find the code below.
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Regards,
Kapil
(forcecube@gmail.com)