Skip to main content
Beta Feature: Computation custom fields are currently in beta. While fully functional, this feature may receive updates and improvements. Please test thoroughly before using in production environments.
What youโ€™ll learn: How to perform mathematical calculations, date manipulations, end-of-week calculations, end-of-month calculations, next-date calculations, and date range calculations directly within your custom fields using mathutil, dateutil, end_of_week, end_of_month, next_date, and date_range utilities.

What Are Computation Custom Fields?

Computation custom fields are advanced dynamic placeholders that can perform calculations and manipulations on your data in real-time. Instead of just inserting static values, these fields can:
  • Perform mathematical operations (addition, subtraction, multiplication, division)
  • Calculate dates (add or subtract days, months, years, hours, minutes, seconds)
  • Find next specific weekday (next Monday, Friday, Sunday, etc.)
  • Calculate end of month (last day of current month)
  • Find next occurrence of day of month (next 5th, 15th, 28th, etc.)
  • Calculate date ranges (formatted list of days from start date + number of days)
  • Create dynamic values based on existing custom field data
Think of them as smart calculators embedded within your custom fields that automatically compute values when your AI conversations start.

Why Use Computation Custom Fields? ๐ŸŽฏ

The Problem:

  • Need to calculate payment amounts with interest or fees
  • Want to set reminder dates based on due dates
  • Require dynamic pricing based on existing values
  • Need follow-up dates calculated automatically

The Solution:

  • Real-time calculations within your prompts
  • No manual math or date calculations needed
  • Dynamic values that update automatically
  • Professional, accurate, and consistent results

Math Utility (mathutil) ๐Ÿ”ข

The mathutil function lets you perform mathematical operations on numeric custom fields.

Basic Syntax

Supported Operations

Math Examples

Adding Late Fees

Result:

Calculating Interest

Result:

Payment Plans

Result:

Discounts

Result:

Advanced Math Examples

Complex Financial Calculations

Pricing Adjustments

Date Utility (dateutil) ๐Ÿ“…

The dateutil function lets you calculate dates by adding or subtracting time periods from existing dates.

Basic Syntax

Supported Time Units

Special Date References

Date Examples

Payment Reminders

Result:

Appointment Scheduling

Result:

Contract Periods

Result:

Advanced Date Examples

Debt Collection Timeline

Subscription Management

End of Week Utility (end_of_week) ๐Ÿ“†

The end_of_week function calculates the next occurrence of a specific day of the week from todayโ€™s date.

Basic Syntax

Day Numbers (Python Convention)

The day numbers follow Pythonโ€™s weekday() convention where Monday is 0 and Sunday is 6. You can also use 7 for Sunday.

How It Works

The end_of_week utility calculates the next occurrence of the specified day:
  • If today is Tuesday and you specify {end_of_week:0} (Monday), youโ€™ll get the date for next Monday (6 days later)
  • If today is Monday and you specify {end_of_week:0} (Monday), youโ€™ll get the date for next Monday (7 days later, not today)
  • The function always returns a future date, never todayโ€™s date

End of Week Examples

Setting Deadlines by Day

Result (assuming today is Wednesday, March 13, 2024):

Weekly Payment Reminders

Appointment Scheduling with Specific Days

Practical Use Cases

Weekly Follow-ups

Business Week Deadlines

Weekend Coordination

End of Month Utility (end_of_month) ๐Ÿ“…

The end_of_month function calculates the last day of the current month.

Basic Syntax

The end_of_month utility is straightforward - it simply returns the last day of the current month. No parameters needed!

How It Works

  • Automatically calculates the last day of the current month
  • Handles varying month lengths (28, 29, 30, or 31 days)
  • Accounts for leap years in February
  • Returns date in format: โ€œDD MMM YYYYโ€ (e.g., โ€œ31 Mar 2024โ€)

End of Month Examples

Monthly Deadlines

Result (assuming today is March 15, 2024):

Monthly Payment Reminders

Subscription Billing

Practical Use Cases

End of Month Campaigns

Billing Cycles

Performance Targets

Financial Deadlines

Next Date Utility (next_date) ๐Ÿ“†

The next_date function calculates the next occurrence of a specific day of the month, making it perfect for setting deadlines, billing dates, and recurring monthly events.

Basic Syntax

Parameters

How It Works

The next_date utility calculates the next occurrence of a specific day of the month:
  • Start Date: Can be any custom field containing a date or {today}
  • Day Number: The target day of the month (1-31)
  • Logic:
    • If current day โ‰ค target day: Returns target day in the current month
    • If current day > target day: Returns target day in the next month
  • Result: Returns the date in โ€œDD MMM YYYY, (DayName)โ€ format

Next Date Examples

From Today for Next 5th

Result (assuming today is November 1, 2024):
Result (assuming today is November 15, 2024):

From Start Date for Next 10th

Result (if StartDate is January 8, 2024):
Result (if StartDate is January 20, 2024):

Monthly Billing Date

Result:
Result (if today is March 20, 2024):

Advanced Next Date Examples

Monthly Payment Deadlines

Billing Cycle Management

Recurring Deadlines

Practical Use Cases

Monthly Payment Reminders

Subscription Renewals

Report Submission Deadlines

Rent Payment Due Dates

Date Range Utility (date_range) ๐Ÿ“Š

The date_range function calculates a date range FROM a start date FOR a specified number of days, making it perfect for creating time-based windows, billing periods, and scheduling ranges.

Basic Syntax

Parameters

How It Works

The date_range utility calculates a date range starting from a specified date:
  • Start Date: Can be any custom field containing a date or {today}
  • Number of Days: Specifies how many days forward from the start date (inclusive)
  • Result: Returns a formatted list showing each day in the range with date and day of week
  • Inclusive: The range includes both the start date and the end date
  • Format: Each day shows as โ€œDD MMM YYYY, DayNameโ€

Date Range Examples

From Today for 6 Days

Result (assuming today is October 21, 2025):

From Start Date for 5 Days

Result:

Payment Window

Result:

Advanced Date Range Examples

Billing Cycle Window

Trial Period Tracking

Project Timeline

Practical Use Cases

Payment Grace Period

Subscription Trial

Campaign Duration

Warranty Period

Combining Multiple Utilities ๐Ÿ”„

You can combine math, date, end-of-week, end-of-month, next-date, and date-range utilities in the same prompt for sophisticated calculations:

Dynamic Payment Scheduling

Interest Calculations with Dates

Weekly and Monthly Deadlines with Discounts

Comprehensive Campaign with All Utilities

Advanced Analytics with Date Ranges

Monthly Billing with Next Date

Required Fields and Dependencies ๐Ÿ“‹

For Date Utilities (dateutil, end_of_week, end_of_month, next_date, date_range):

Mandatory Fields for Date Operations: When using any date utilities (dateutil, end_of_week, end_of_month, next_date, or date_range), both {today} and {time_zone} fields are mandatory and must be included in your prompt. During testing or when uploading audience data, you must provide the time_zone field, while today will be filled automatically by Vodex.

Required Fields:

  • today - Current date/time (automatically provided by Vodex)
  • raw_today - Raw timestamp format (automatically provided, used by end_of_week, end_of_month, and next_date)
  • time_zone - Userโ€™s timezone (must be provided)
  • Date fields - For date_range and next_date, start date fields must exist and contain valid dates

Valid Timezone Formats:

Important: The time_zone field must be a valid timezone. Invalid timezones will cause โ€œSomething went wrongโ€ errors.
The field today should be left blank when making calls via Agent Call, Campaign Run, or API. Vodex will fill it automatically using the time_zone field. For more details about these base fields, see our Custom Fields Introduction.

For Math Utilities:

  • The referenced field must contain numeric data
  • Field must exist in your custom fields data
  • Values must be convertible to numbers

Error Handling and Validation โš ๏ธ

Common Math Errors

Common Date Errors

Error Examples

Math Error - Division by Zero:

Date Error - Missing Unit:

Field Missing Error:

End of Week Error - Invalid Day Number:

Missing Required Field Error:

Date Range Error - Missing Field:

Date Range Error - Invalid Number:

Date Range Error - Negative Days:

Next Date Error - Invalid Day of Month:

Next Date Error - Missing Field:

Best Practices for Computation Fields ๐Ÿ†

1. Always Validate Your Data

  • Ensure numeric fields contain valid numbers
  • Verify date fields have proper date formats
  • Test with sample data before going live

2. Use Descriptive Field Names

3. Handle Edge Cases

  • Plan for missing data scenarios
  • Consider what happens with zero values
  • Test with various data types

4. Keep Calculations Simple

  • Use straightforward operations when possible
  • Break complex calculations into multiple fields
  • Make calculations easy to understand and verify

5. Test Thoroughly

  • Test with different numeric values
  • Try various date scenarios
  • Verify timezone handling

Real-World Use Cases ๐ŸŒ

Debt Collection Agency

Healthcare Appointment Reminders

Subscription Services

Real Estate Follow-ups

Testing Your Computation Fields ๐Ÿงช

Testing Checklist

  • Math operations work correctly - Test all four operations (+, -, *, /)
  • Date calculations are accurate - Verify dateutil arithmetic
  • End of week calculations - Test all day numbers (0-7)
  • End of month calculations - Test across different months and leap years
  • Next date calculations - Test with different days of month (1-31)
  • Date range calculations - Test with different day ranges
  • Field references resolve - Ensure all fields exist
  • Error handling works - Test with invalid data
  • Timezone handling correct - Test with different timezones
  • Conversation flows naturally - Verify the computed values make sense
  • Combined utilities work - Test mixing multiple utility types

Sample Test Data

Expected Results

Troubleshooting Guide ๐Ÿ”ง

Math Issues

Problem: Field shows wrong calculation
  • Check field contains numeric data
  • Verify operation syntax
  • Test with simple values first
Problem: Division returns unexpected results
  • Ensure youโ€™re not dividing by zero
  • Check for decimal vs integer division
  • Verify the divisor value

Date Issues

Problem: Date calculation fails
  • Verify timezone is properly set
  • Check source date format
  • Ensure time unit is included
  • Confirm raw_today is available (for end_of_week/end_of_month)
Problem: Wrong date returned
  • Confirm timezone is correct
  • Check if daylight saving affects calculation
  • Verify source date is accurate

End of Week Issues

Problem: Wrong weekday calculated
  • Verify day number (0=Monday, 6=Sunday)
  • Check that raw_today field exists
  • Confirm timezone is set correctly
Problem: Returns today instead of next occurrence
  • System always returns next occurrence, not current day
  • If you need current day, use instead

End of Month Issues

Problem: Wrong last day calculated
  • Verify raw_today field exists
  • Check timezone setting
  • Confirm current month/year is correct
Problem: Leap year not handled
  • System automatically handles leap years
  • Verify raw_today format is correct

Next Date Issues

Problem: Wrong date calculated
  • Verify start date field exists and contains valid date
  • Check that day number is between 1-31
  • Confirm timezone is set correctly
Problem: Invalid day of month error
  • Use only valid days of the month (1-31)
  • Avoid days that donโ€™t exist in certain months (e.g., Feb 30)
  • System will automatically handle month boundaries
Problem: Missing field error
  • Ensure the start date field exists in your custom fields
  • Verify field name spelling and case sensitivity
Problem: Date parsing error
  • Start date must be in a valid date format
  • System handles various date formats automatically
  • Check that raw_today is available when using

Date Range Issues

Problem: Wrong end date calculated
  • Verify start date field exists and contains valid date
  • Check that number of days is a positive integer
  • Confirm timezone is set correctly
Problem: Invalid number error
  • Use only numeric values for days (5, 30, 90)
  • Avoid non-numeric characters or negative numbers
Problem: Missing field error
  • Ensure the start date field exists in your custom fields
  • Verify field name spelling and case sensitivity
Problem: Date format issues
  • Start date must be in a valid date format
  • System handles various date formats automatically

Next Steps ๐Ÿš€

Now that you understand computation custom fields:
  1. Start with simple calculations - Begin with basic math operations
  2. Test thoroughly - Verify calculations with sample data
  3. Add date computations - Include timeline calculations with dateutil
  4. Use weekday and month-end features - Leverage end_of_week and end_of_month
  5. Set monthly deadlines - Use next_date for recurring monthly dates
  6. Calculate time periods - Use date_range for duration analysis
  7. Combine all utilities - Create sophisticated prompts with multiple computation types
  8. Monitor and optimize - Track performance and accuracy

Quick Reference Summary ๐Ÿ“š

Ready to supercharge your custom fields? Computation fields unlock powerful dynamic capabilities that make your AI conversations more intelligent, accurate, and useful. Start implementing them today to create more sophisticated and helpful interactions.

Need the basics first? Check out our Custom Fields Introduction and Best Practices guides before diving into computation features.