Skip to main content

Hello All,

Im trying to use Zapier to take total expense data from my quickbooks P&L from the previous month and insert that value into a particular line in an excel sheet. I’m having difficulty specifying “Last month” within the Quickbooks API query. I have the following suggestion below from Zapier but I don't know how to dynamically change the date in the url query to reflect “last month”. Any thoughts?

(company ID was obviously changed for privacy, lol)

 https://api.quickbooks.com/v3/company/1234123412341234/reports/ProfitAndLoss?start_date=<start_date>&end_date=<end_date>"

Hi there ​@Rick G,

Before we dig deeper into this, would you mind sharing a detailed screenshot of how your Zap is configured? Also, please share a screenshot of the “CONFIGURE” section of your action step.

Please don't include personal information in the screenshot, or be sure blur out any personal information.

Thanks!


Hi ​@Rick G,

Try adding a Javascript code step to get the start and end dates of the month prior to the current date. Then you can plug those dates into your API call to QuickBooks. Code and screenshots below:

const currentDate = new Date();

// Calculate the first day of the previous month
const firstDayOfPreviousMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1);

// Calculate the last day of the previous month
const lastDayOfPreviousMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);

// Prepare the output with the start and end dates formatted as ISO strings
output = {
startDate: firstDayOfPreviousMonth.toISOString().split('T')[0], // Format: YYYY-MM-DD
endDate: lastDayOfPreviousMonth.toISOString().split('T')[0] // Format: YYYY-MM-DD
};