TO_ACTIVITY_BITS

All functions > BUSINESS_ACTIVITY > TO_ACTIVITY_BITS

Returns the activity bits for the given array of activity dates and date reference.

Syntax

TO_ACTIVITY_BITS(activity: ARRAY<DATE>, date_ref: DATE) → BIGINT
sql

Arguments

ParameterTypeRequiredDescription
activityARRAY<DATE>YesArray of dates when user was active
date_refDATEYesReference date to encode activity relative to
active_beforeANYYesOptional flag if user was active before tracking period

Returns

BIGINT - Bit-packed representation of activity over last 56 days

Notes

  • Encodes up to 56 days of activity into a single 64-bit integer
  • Each bit represents one day (1 = active, 0 = inactive)
  • Bit 0 (LSB) = reference date, Bit 1 = day before, etc.
  • Bit 56 (MSB) = flag for activity before 56-day window
  • Efficient storage for user activity tracking
  • Use with IS_ACTIVE, COUNT_ACTIVE, ACTIVITY_STATUS functions
  • Inverse of FROM_ACTIVITY_BITS
Last update at: 2025/10/13 10:23:46