0

i need to pass SOQL query to get the first and last day of the previous month.

Example Query: Select Name, ID FROM Audit__C WHERE Audit_Month__C BETWEEN 'previous month start date (2020-04-01)' AND 'previous month end date (2020-04-30)'

i will be passing today's date in both the date area. which SOQL date function helps me in getting previous month first date and last date while passing today's date?

1 Answer 1

2

You can use LAST_MONTH date literal like this:

Select Name, ID FROM Audit__C WHERE Audit_Month__C = LAST_MONTH

From documentation:

Starts 00:00:00 on the first day of the month before the current day and continues for all the days of that month.

More info on date literals: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .