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
Abhish ChalkeAbhish Chalke 

I want to subtract 5 hrs from my date field but the date which I get is in this format '2018-12-31 00:00:00' How should I subtract 5 hrs from this date

Raj VakatiRaj Vakati
Try like this
 
String s = '2018-12-31 00:00:00';
DateTime d = DateTime.valueOf(s) ;
System.debug('d'+d);
DateTime newDate = d.addHours(-5);
System.debug('new date'+newDate);

User-added image