Delete user-archive records by passing a date-based filter to uaArchiveDelete. The available C-script uses DATEDIFF with CURRENT_TIMESTAMP and removes rows whose calculated age is greater than 30 days.
Deletion expression
uaArchiveDelete(hArchive, "datediff(day,date_field,current_timestamp) > 30 ");
hArchive identifies the open user archive, while date_field must be replaced by the archive column containing each record's date. The filter compares that value with the database server's current timestamp.
Boundary and data requirements
| Element | Required interpretation |
|---|---|
date_field |
A date/time-compatible archive field |
CURRENT_TIMESTAMP |
The current timestamp evaluated by the SQL engine |
> 30 |
Delete only rows for which the calculated difference exceeds 30 days |
The strict greater-than operator does not match a result equal to 30. If the requirement means “30 days old or older,” review whether the predicate should use >= 30; confirm the desired boundary before changing the production archive.
Execute and verify the cleanup
- Confirm that
hArchivereferences the intended user archive. - Confirm that
date_fieldcontains valid date/time values and that the SQL engine accepts the shownDATEDIFFandCURRENT_TIMESTAMPsyntax. - Run the
uaArchiveDeletecall with the filter. - Inspect the remaining archive rows around the 30-day boundary. Verify that newer rows remain and that rows matching the predicate were removed.
The evidence does not identify the runtime version, database engine, date format, return value, or error-handling interface. Test the predicate on noncritical archive data first, especially if the installation uses locale-dependent date handling.
FAQ
How do I delete user archive rows older than 30 days?
Call uaArchiveDelete(hArchive, "datediff(day,date_field,current_timestamp) > 30 "), replacing date_field with the archive's date/time column.
Does greater than 30 delete rows that are exactly 30 days old?
No. The predicate > 30 excludes a calculated difference equal to 30; use >= 30 only if the requirement explicitly includes that boundary.
What should I check before running uaArchiveDelete?
Verify the archive handle, the date/time field, SQL syntax compatibility, and the intended 30-day boundary. Then confirm the result by inspecting rows immediately before and after that boundary.