+ Start a Discussion
Rahul H 4Rahul H 4 

how to truncate date field with value : 2019-08-19T23:16:00Z to display 2019-08-19 using Apex trigger?

Khan AnasKhan Anas (Salesforce Developers) 
Hi Rahul,

Greetings to you!

Date() is used to get the date from datetime field.
Datetime dt = (Datetime)Account.Start_Date__c;
Date ModifiedDate = dt.Date();

format() method returns the Date as a string using the locale of the context user.
Datetime dt = (Datetime)Account.Start_Date__c; 
Date d = dt.format('MM/dd/yyyy');

Please refer to the below links which might help you further.




I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas