TO_ACTIVITY_BITS
All functions > BUSINESS > TO_ACTIVITY_BITS
Returns the activity bits for the given array of activity dates and date reference.
Signatures
Returns: Bit-packed representation of activity over last 56 days
TO_ACTIVITY_BITS(activity: ARRAY<DATE>, date_ref: DATE, [active_before: BOOLEAN]) → BIGINT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
activity | ARRAY<DATE> | Yes | Array of dates when user was active |
date_ref | DATE | Yes | Reference date to encode activity relative to |
active_before | BOOLEAN | No | Optional flag if user was active before tracking period |
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
On this page