Converting DateTime to Date in Salesforce
Solution 1: Create a date newInstance() and pass the Year, Month, and Day from the DateTime.
1 2 3 | DateTime dt = System.now();Date d = Date.newInstance(dt.year(), dt.month(), dt.day());System.debug('Print Date:' + d); |
Solution 2: Get date from the DateTime using Date() method.
1 2 3 | DateTime dt = System.now()Date d = dt.date();System.debug('Print Date:' + d); |


0 Comments