Knowledgebase
[QODBC Desktop] Writing UPDATE Queries in QODBC - Timestamp Syntax and Common Field Flags
Posted by William - QODBC Support on 01 October 2026 12:32 PM

[QODBC Desktop] Writing UPDATE Queries in QODBC - Timestamp Syntax and Common Field Flags

Problem Description:

QODBC read-write users need to update field values across multiple QuickBooks tables (e.g., PurchaseOrder, Invoice, CreditMemo, SalesOrder) using SQL UPDATE statements. A common stumbling block is using the wrong date/time format for the TimeCreated field - QuickBooks stores timestamps internally, not plain dates. Using a date literal ({d ...}) instead of a timestamp literal ({ts ...}) causes a data type mismatch error.

Affected products: QODBC Desktop Read-Write, QuickBooks Desktop (Enterprise, Pro, Premier)
Expected outcome: UPDATE queries execute successfully using timestamp format for TimeCreated and correct boolean/integer values for field flags.

Symptoms:

  • "ERROR [42S00] [QODBC] Data type mismatch for one or more fields. Invalid operand for operator: >=" - occurs when using {d 'YYYY-MM-DD'} date format on a TimeCreated (timestamp) column.
  • Error 3210 - "The ‘IsManuallyClosed’ field has an invalid value" - attempting to set IsManuallyClosed on records that are already closed or have TotalAmount = 0.
  • UPDATE queries silently succeed, but values don't change in QuickBooks (typically because the WHERE clause filtered out all matching rows due to format mismatch).

Cause:

  1. Wrong literal type for TimeCreated: The TimeCreated field in QuickBooks is stored as a timestamp, not a date. Using the SQL date literal syntax {d 'YYYY-MM-DD'} produces a data type mismatch because QODBC cannot compare a date value against a timestamp column.
  2. Record already meets closure criteria: IsManuallyClosed can only be set to 1 (True) on records that are still open. If the record is already closed, fully received, or has TotalAmount = 0, QuickBooks rejects the update.

Environment:

ProductVersion / Detail
QODBC Driver 2024+ (Read-Write license required)
QuickBooks Edition Desktop, Enterprise, Pro, Premier
SQL Literal for TimeCreated Must use timestamp: {ts 'YYYY-MM-DD HH:MM:SS.000'}

Solution:

  1. Use timestamp literal syntax ({ts}) for TimeCreated. Always format as {ts 'YYYY-MM-DD HH:MM:SS.000'}, not {d 'YYYY-MM-DD'}. Example:
UPDATE PurchaseOrder
SET IsManuallyClosed = False
WHERE TimeCreated >= {ts '2017-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2022-01-01 00:00:00.000'}
  1. Use False (not true) for boolean fields in QODBC. While some ODBC drivers accept both, QODBC consistently handles True/False (capitalized) or 0/1 for integer/boolean columns.
  2. Add guard clauses to avoid Error 3210. Before setting IsManuallyClosed = 1, ensure the record is still open and has a non-zero amount:
UPDATE PurchaseOrder
SET IsManuallyClosed = 1
WHERE TimeCreated >= {ts '2017-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2022-01-01 00:00:00.000'}
  AND IsFullyReceived = 0
  AND IsManuallyClosed = 0
  AND TotalAmount > 0
  1. For IsToBePrinted / IsToBeEmailed flags on multiple tables, use the same timestamp pattern:
UPDATE Invoice
SET IsToBePrinted = False, IsToBeEmailed = False
WHERE TimeCreated >= {ts '2027-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2027-12-31 00:00:00.000'}
UPDATE SalesOrder
SET IsToBePrinted = False, IsToBeEmailed = False
WHERE TimeCreated >= {ts '2027-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2027-12-31 00:00:00.000'}
UPDATE CreditMemo
SET IsToBePrinted = False, IsToBeEmailed = False
WHERE TimeCreated >= {ts '2003-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2027-12-31 00:00:00.000'}
  1. Handle records with TotalAmount = 0 manually. Records where the total amount is zero cannot be updated via IsManuallyClosed through QODBC - they must be marked manually in the QuickBooks UI. Filter these out with TotalAmount > 0 in your WHERE clause to avoid Error 3210.
  2. Verify before bulk updates. Run a SELECT first with the same WHERE clause to confirm which rows will be affected:
SELECT TxnID, TimeCreated, IsManuallyClosed, TotalAmount
FROM PurchaseOrder
WHERE TimeCreated >= {ts '2017-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2022-01-01 00:00:00.000'}
  AND IsFullyReceived = 0
  AND IsManuallyClosed = 0

SQL Examples:

Update a single record by transaction ID (faster, more precise):

UPDATE PurchaseOrder
SET IsManuallyClosed = 0
WHERE TxnId = 'BF7F-1828866559'

Update IsManuallyClosed across a date range with all guard clauses:

UPDATE PurchaseOrder
SET IsManuallyClosed = 1
WHERE TimeCreated >= {ts '2017-01-01 00:00:00.000'}
  AND TimeCreated <= {ts '2022-01-01 00:00:00.000'}
  AND IsFullyReceived = 0
  AND IsManuallyClosed = 0
  AND TotalAmount > 0

Example Scenarios:

Scenario 1 - Closing 40,000+ Purchase Orders:

A customer with over 40,000 records needed to set IsManuallyClosed and various flag fields on historical purchase orders. After learning to use timestamp format for TimeCreated (instead of the date format that caused data type mismatch), they ran UPDATE queries with TotalAmount > 0 and IsManuallyClosed = 0 guard clauses. Records with TotalAmount = 0 (~380 rows) were handled manually in the QuickBooks UI.

Scenario 2 - Bulk flag updates on Invoices:

A customer needed to clear IsToBePrinted and IsToBeEmailed flags on thousands of invoices across a date range. They used a single UPDATE with timestamp syntax and verified the row count with a matching SELECT before committing.

Additional Notes:

  • Date format reference: For full details on all QuickBooks date/time formats supported by QODBC, see the official KB article: "How are dates formatted in SQL queries when using the QuickBooks generated timestamps."
  • Error 3210 is a QuickBooks validation error, not a QODBC bug. It means QuickBooks itself rejected the value because the record doesn't meet the business rule (e.g., already closed, zero total amount).
  • Always test with SELECT first. Run your UPDATE's WHERE clause as a SELECT to see exactly which rows will be affected before executing the UPDATE.
  • Transaction safety: QODBC does not support explicit SQL transactions (BEGIN/COMMIT/ROLLBACK). Each UPDATE is committed immediately. Back up your QuickBooks company file before bulk updates.

How are dates formatted in SQL queries when using the QuickBooks generated timestamps QODBC Read-Write - Enabling UPDATE and DELETE Operations

Keywords:

QODBC UPDATE Query Timestamp Format TimeCreated IsManuallyClosed IsToBePrinted IsToBeEmailed Data Type Mismatch Error 3210 PurchaseOrder Invoice CreditMemo SalesOrder Bulk Update Read-Write License
(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).