About this question
I am creating dynamic SOQL query for the search page with the below-mentioned code: VFP
Apex:
My Invoice_Date__c is a date field in the object
If I execute the following code in Anonymous window I do see the correct format but with my building dynamic SOQL I see the 2017-07-17 00:00:00
Date d = s.Invoice_Date__c; string dateStr = DateTime.newInstance(d.year(),d.month(),d.day()).format('yyyy-MM-dd'); system.debug('//' + dateStr);
Dynamic query building:
if (s.Invoice_Date__c != null) { Datetime d = s.Invoice_Date__c; String dateOutput
Despite selecting today’s date , in debug its displaying another date. How to format date to Yyyyy-MM-Dd through Apex?