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
VinayKodishalaVinayKodishala 

How to convert DateTime to Date format in SOQL query

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Vinay,

We can use DAY_ONLY function. Please find the below article for the same.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_date_functions.htm

If this solution helps, Please mark it as best answer.

Thanks,
 
Suraj Tripathi 47Suraj Tripathi 47

Hi Vinay,

use this code, it will help you.

 

Follow these steps -:

1.    DateTime dt = System.now()
2.    Date extactedDate= dt.date();
3.    System.debug(' date is-----'+extactedDate);



If you find your Solution then mark this as the best answer.

Thank you!
Regards,
Suraj Tripathi