Activity Forums Salesforce® Discussions How to convert Date/Time to a Date in Salesforce?

  • Deepak

    Member
    June 11, 2020 at 5:39 am

    You can convert a Date/Time to a Date by using the DATEVALUE() function, which takes a Date/Time or Text value and returns a Date.

  • Shweta

    Member
    June 11, 2020 at 6:33 am

    We can create a date newInstance() and pass the year, month, day from the DateTime to convert DateTime to date. e.g:
    DateTime dTime= System.now();
    Date newDate = date.newinstance(dTime.year(), dTime.month(), dTime.day());
    OR, we can also use Date() method to convert DateTime to date. E.g.:
    DateTime dTime= System.now();
    Date newDate = dTime.date();

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos