RECENCY

All functions > BUSINESS > RECENCY

Returns the number of days since the last active day for the given activity bits

Signatures

Returns: Number of days since last activity (0 = today, 1 = yesterday, etc.), NULL if never active

RECENCY(activity_bits: BIGINT) → BIGINT
sql
ParameterTypeRequiredDescription
activity_bitsBIGINTYesBit-packed activity representation

Notes

  • Finds most recent active day using bit operations
  • Returns 0 if active today, 1 if yesterday, etc.
  • Returns NULL if activity_bits = 0 (never active)
  • Uses efficient bit isolation technique (x & -x)
  • Fast operation - no iteration required
  • Essential for recency analysis and churn prediction
  • Complements frequency metrics from COUNT_ACTIVE
Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19