Above is my code. Why am i getting yesterdays date?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
A possible cause would be if the field
Transaction_Date__c is a
DateTime field, assigning a
Date to it would set the hours/minutes/seconds to zero, and then the automatic timezone handling for your
User would subtract (or add) hours and so move the
Date part to the previous day. A quick fix for that would be:
but better to change the type of the field
Date if that is what it represents.
If not the above, search for other code or configuration in your system that modifies the
Transaction_Date__c field as the code you have posted looks correct.