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
Kimberly Dy 16Kimberly Dy 16 

Trigger Help - Updating a CS field

Hello,

I'm trying to use a trigger to update a custom date/time field from a date field in the same object. Here's a simple trigger I wrote since I don't know much about triggers. When I tested this, I noticed that the trigger did update the custom date/time field but it updated the wrong day. The original date field is 10/16/16 and the trigger updated the custom date/time field to 10/5/16. Can anyone help me with the trigger I wrote and see what I missed? Also, is it possible to update the field Closed_Date_Time__c from the field CloseDate and Close_Date_Time__c (picklist field)? 

trigger UpdateCloseDateTIme on Opportunity (before update)
{for (Opportunity opportunity: Trigger.new){
Opportunity.Close_Date_Time__c = Opportunity.CloseDate;}
}

Thank you!