Activity Forums Salesforce® Discussions DateTime.day() returning inconsistent value when created from system.today()

  • Surbhi

    Member
    May 24, 2016 at 10:43 AM

    Hi Himanshu,

    The problem was with initializing the DateTime variable by casting from a Date. Instead of directly casting the Date to a DateTime, the DateTime.newInstance(date, time) method should be used to construct the DateTime in the local time zone as Date doesn’t have any time zone.

    Thanks

Log In to reply.