Thursday, August 4, 2011

Conver DateTime to Date Type in Salesforce Apex



Dear Folks,
Here is the code to convert DateTime to Date Type.

DateTime Dt = System.today();
Date D = Date.newInstance(Dt.year(),Dt.Month(),Dt.day());




2 comments:

  1. Actually there is an easier way to convert it to date now. Not sure if the below method existed when u created the above Post.

    DateTime Dt = Datetime.newinstance(2008, 2, 5, 8, 30, 12);
    Date D = Dt.date();

    Try it out!

    ReplyDelete