I'm trying to change the value of a Datetime instance to 8am the next day. Going to the next day is fine:


But how can I change the time to 8am?

1 Answer 1


You can use addHours() and many other datetime specific methods, or if you don't know the current hour, your can use something like:

datetime.newInstance(lead.Follow_Up_Date_Time__c.year(), lead.Follow_Up_Date_Time__c.month(), lead.Follow_Up_Date_Time__c.day() + 1, 8, 0, 0);

For more information: Datetime Class

  • That kinda works but goes back a day and into the PM?
    – t56k
    Oct 3, 2016 at 22:58
  • What timezone are you in? try newInstanceGmt().
    – Nick C
    Oct 3, 2016 at 23:00
  • Ah yep, timezone was my fault. Thanks for your answer!
    – t56k
    Oct 3, 2016 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .