Bookkeeping
Query Functions in Bookkeeping Tools: What They Are and When to Use Them
How query functions like date conversions and string trimming help bookkeepers filter, test and clean ledger data during the close, with worked examples.
Updated 2026-08-20 · 3 min read
Query functions are the small built-in operations you can use inside a filter or export rule in accounting software. Instead of pulling a raw list of transactions, you can test values, reshape dates, or strip stray spaces before the data reaches your working paper. Used well, they turn a messy extract into something you can reconcile.
What is a query function?
A function takes one or more inputs, called arguments, and returns a single result. ABS(-10.15) returns 10.15. ALLTRIM(" abcde ") returns abcde. The software does the work; you supply the logic.
In bookkeeping terms, a function is a test or a transformation. You use tests to decide which rows matter, and transformations to make values comparable. Most month-end work uses both.
The functions that earn their keep at month-end
A handful of functions cover most close-related needs:
- Date conversion. Functions that turn a date into a sortable string, such as
yyyymmdd, make period cut-off testing possible. If your extract shows09/01/08, a date-to-string function gives20080901, which sorts correctly and matches cleanly against a period key. - Date parts. Functions that extract the day, month, or year let you group by period or flag transactions dated on the last day of the month, a common cut-off risk area.
- String trimming. Removing leading and trailing spaces prevents false mismatches when you join a supplier list to a ledger extract.
" abcde "and"abcde"are different values to a computer. - Substring position. Finding where one string sits inside another helps you split combined reference fields, such as an account code buried in a memo.
- Conditional logic. An inline "if" function returns one value when a condition holds and another when it does not. This is how you build a review column that flags, say, any amount above a threshold.
- Empty tests. Checking whether a field is blank catches missing references and incomplete memo lines before they reach the working paper.
A worked example: cut-off testing
Suppose you export December's purchases and want to confirm nothing belonging to January has slipped in. You convert each transaction date to a yyyymmdd string, then filter for values outside 20081201 to 20081231. Anything surviving the filter is either a cut-off error or a posting mistake, and each one goes on the exceptions list with a note.
The same approach works in reverse for accruals. Convert the January invoice dates, filter for goods or services received in December, and you have your accrual population ready to value.
Where functions stop being the answer
Functions operate on the data as it stands. If the ledger itself is damaged, dates are corrupt, or balances disagree with the source, no filter will fix that. That is a data integrity problem, not a query problem. Preserve a backup before anyone touches the file, and hand the repair itself to a specialist; see our QuickBooks data repair service when the fault sits in the file rather than the postings.
Practical habits
Keep queries readable and document them in the working paper, so a reviewer can reproduce the population. Test a function on a few known rows before trusting it across a full extract. And remember that a filter only ever narrows a list; the judgement about what belongs in the period is still yours.
General information for people who keep the books. It is not accounting, tax or legal advice, and it is not a substitute for your own professional judgement on your own figures.