function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naga Balji BNaga Balji B 

how to separate date and time fieds from created date in apex?

Mahesh DMahesh D
Hi Naga,

Please find the below code:
 
Datetime nowTime = Datetime.now();
String DateStr = String.valueOf(nowTime.date());
String timeStr = String.valueOf(nowTime.time());

System.debug(DateStr + ' : ' + timeStr);
Please do let me know if it helps you.

Regards,
Mahesh
Abhishek Ranjan 10Abhishek Ranjan 10
https://developer.salesforce.com/forums/?id=906F00000008uO1IAI
Mahesh DMahesh D
Hi Naga,

For more information:

date()
Returns the Date component of a Datetime in the local time zone of the context user.

time()
Returns the time component of a Datetime in the local time zone of the context user.

For more information:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm%23apex_methods_system_datetime

http://salesforce.stackexchange.com/questions/5430/how-to-split-startdatetime-field-of-activity-event


Regards,
Mahesh