+ Start a Discussion
Kimberly Dy 16Kimberly Dy 16 

Trigger Help - Updating a CS field


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!