To get Day, Month and Year from Date using Apex in Salesforce

Sample Code:

Date datobj;
Integer dy = datobj.day();
Integer mon = datobj.month();
Integer yr = datobj.year();

Cheers!!!

3 comments:

  1. how to compare year in date with current year using trigger?

    ReplyDelete
    Replies
    1. Check this http://www.infallibletechie.com/2016/10/how-to-get-current-year-using-apex-in.html for more info.

      Delete