Skip to content

Subtract From A Date

Before using this node, ensure you have:

  • Basic understanding of workflow creation in Agentic WorkFlow
  • Appropriate browser permissions configured (if applicable)
  • Required dependencies installed and configured

The Subtract From A Date node provides comprehensive date arithmetic capabilities for subtracting multiple time periods from existing dates. This node handles complex date calculations including timezone conversions, business day arithmetic, and flexible time unit operations, making it essential for deadline calculations, historical analysis, and temporal workflow.

Subtract From A Date serves as a powerful date arithmetic tool that allows you to:

  • Subtract days, weeks, months, years, hours, minutes, or seconds from dates
  • Handle timezone conversions and daylight saving time transitions
  • Calculate business days excluding weekends and holidays
  • Support multiple date input formats and output formatting
  • Perform batch date calculations for multiple dates simultaneously
  • Flexible Time Units: Support for years, months, weeks, days, hours, minutes, and seconds
  • Timezone Awareness: Automatic timezone handling and conversion capabilities
  • Business Day Calculations: Skip weekends and custom holiday lists when subtracting
  • Multiple Date Formats: Accept and output dates in multiple standard formats
  • Batch Processing: Process multiple dates in a single operation
  • Historical Analysis: Calculate past dates for trend analysis and reporting
  • Deadline Tracking: Determine start dates based on known deadlines
  • Data Retention: Calculate cutoff dates for data archival and cleanup
  • Business Logic: Implement time-based business rules and historical workflows
ParameterTypeDescriptionExample
input_datestring/dateBase date to subtract time from"2024-01-15T10:00:00Z"
amountnumberAmount of time units to subtract30
unitstringTime unit: “years”, “months”, “weeks”, “days”, “hours”, “minutes”, “seconds”"days"
ParameterTypeDefaultDescriptionExample
timezonestring"UTC"Target timezone for calculations"America/New_York"
business_days_onlybooleanfalseSkip weekends in day calculationstrue
holidaysarray[]List of holiday dates to skip["2024-12-25", "2024-01-01"]
output_formatstring"ISO"Output format: “ISO”, “timestamp”, “custom”"YYYY-MM-DD"
{
"input_date": "2024-01-15T09:00:00",
"amount": 10,
"unit": "days",
"timezone": "America/New_York",
"business_days_only": true,
"holidays": [
"2024-01-01",
"2024-01-05",
"2024-12-25"
],
"output_format": "YYYY-MM-DD HH:mm:ss",
"weekend_days": [0, 6],
"custom_rules": {
"end_of_month_handling": "preserve_day",
"leap_year_handling": "standard"
}
}
{
"date": "2024-01-15T10:00:00Z",
"subtraction_config": {
"amount": 30,
"unit": "days",
"business_days_only": false
},
"timezone_info": {
"input_timezone": "UTC",
"output_timezone": "America/New_York"
}
}
{
"original_date": "2024-01-15T10:00:00Z",
"result_date": "2023-12-16T05:00:00-05:00",
"calculation_details": {
"amount_subtracted": 30,
"unit": "days",
"business_days_skipped": 0,
"holidays_skipped": 0,
"timezone_applied": "America/New_York"
},
"metadata": {
"calculation_time": 15,
"input_format": "ISO",
"output_format": "ISO",
"dst_transition": false
}
}

Example 1: Data Retention Cutoff Calculation

Section titled “Example 1: Data Retention Cutoff Calculation”

Scenario: Calculate the cutoff date for data retention (90 days ago)

Configuration:

{
"input_date": "2024-01-15T09:00:00Z",
"amount": 90,
"unit": "days",
"output_format": "YYYY-MM-DD"
}

Input Data:

{
"current_date": "2024-01-15T09:00:00Z",
"retention_policy": "90_days"
}

Expected Output:

{
"original_date": "2024-01-15T09:00:00Z",
"result_date": "2023-10-17",
"calculation_details": {
"amount_subtracted": 90,
"unit": "days",
"business_days_skipped": 0,
"holidays_skipped": 0
}
}

Example 2: Business Day Calculation for Project Planning

Section titled “Example 2: Business Day Calculation for Project Planning”

Scenario: Calculate project start date based on deadline and required working days

Configuration:

{
"input_date": "2024-01-31T17:00:00",
"amount": 15,
"unit": "days",
"business_days_only": true,
"holidays": ["2024-01-15", "2024-01-29"],
"timezone": "America/New_York"
}

Workflow Integration:

Deadline Input → Subtract From A Date → Project Scheduler
↓ ↓ ↓
deadline start_date project_plan

Complete Example:

{
"input": {
"project_deadline": "2024-01-31T17:00:00",
"required_working_days": 15,
"company_holidays": ["2024-01-15", "2024-01-29"]
},
"processing": {
"subtract_business_days": true,
"exclude_holidays": true,
"skip_weekends": true
},
"output": {
"project_start_date": "2024-01-08T17:00:00-05:00",
"calculation_summary": {
"working_days_subtracted": 15,
"calendar_days_spanned": 23,
"weekends_skipped": 6,
"holidays_skipped": 2
}
}
}

This example demonstrates the fundamental usage of the SubstractFromDate node in a typical workflow scenario.

Configuration:

{
"date": "example_value",
"format": true
}

Input Data:

{
"data": "sample input data"
}

Expected Output:

{
"result": "processed output data"
}

This example shows more complex configuration options and integration patterns.

Configuration:

{
"parameter1": "advanced_value",
"parameter2": false,
"advancedOptions": {
"option1": "value1",
"option2": 100
}
}

Example showing how this node integrates with other workflow nodes:

  1. Previous NodeSubstractFromDateNext Node
  2. Data flows through the workflow with appropriate transformations
  3. Error handling and validation at each step
  • Nodes: Current Date → Subtract From A Date → Database Query → Analytics
  • Use Case: Analyze data from a specific time period in the past
  • Configuration Tips: Use business_days_only for business-focused analysis
  • Nodes: Get Current Date → Subtract From A Date → Filter → Delete Records
  • Use Case: Clean up old data based on retention policies
  • Data Flow: Current time → cutoff date → filtered records → cleanup action
  • Performance: Use batch processing for multiple date calculations when possible
  • Error Handling: Validate input dates and handle edge cases like month boundaries
  • Data Validation: Ensure subtraction amounts are positive numbers
  • Resource Management: Cache holiday lists to avoid repeated API calls
  • Symptoms: Unexpected dates when subtracting months across month boundaries
  • Causes: Different month lengths causing day overflow or underflow
  • Solutions:
    1. Use end_of_month_handling configuration for consistent behavior
    2. Consider using days instead of months for precise calculations
    3. Test calculations around month boundaries
  • Prevention: Use day-based calculations when month precision isn’t required

Issue: Business Day Calculation Inconsistencies

Section titled “Issue: Business Day Calculation Inconsistencies”
  • Symptoms: Incorrect business day counts or unexpected date results
  • Causes: Overlapping weekend and holiday exclusions or incorrect holiday formats
  • Solutions:
    1. Ensure holiday dates are in YYYY-MM-DD format
    2. Check weekend_days configuration (0=Sunday, 6=Saturday)
    3. Verify holiday list doesn’t include weekends unless intended
  • Prevention: Use standardized holiday date formats and test with known dates
  • Slow Calculations: Reduce the number of holidays in the list or use caching
  • Memory Usage: Process large date arrays in batches rather than all at once
  • Timezone Lookups: Cache timezone data for frequently used timezones
  • Date Range: Supports dates from 1900-01-01 to 2100-12-31
  • Precision: Calculations accurate to the second level
  • Historical Data: Timezone rules may not be accurate for historical dates before 1970
  • Future Changes: Timezone rule changes may affect calculations
  • Browser Support: Some older browsers may have limited timezone support
  • Input Size: Maximum 1000 dates per batch operation
  • Holiday List: Maximum 100 holidays per calculation
  • Processing Time: Complex calculations timeout after 30 seconds

Field Transformation: Process of modifying data field names, types, or values

Type Conversion: Converting data from one type to another (string, number, boolean, etc.)

Data Validation: Process of ensuring data meets specified criteria and constraints

Schema: Structure definition that describes the format and constraints of data

Serialization: Process of converting data structures into a format for storage or transmission

  • data processing
  • field manipulation
  • type conversion
  • data validation
  • formatting
  • transformation
  • “transform”
  • “convert”
  • “format”
  • “edit”
  • “modify”
  • “process”
  • “validate”
  • “clean”
  • “restructure”
  • data cleaning
  • format conversion
  • field manipulation
  • data validation
  • report generation
  • data processing
  • AddToADate: Use when you need different approach to similar functionality
  • GetTimeBetweenDates: Use when you need different approach to similar functionality
  • GetCurrentDate: Works well together in workflows
  • FormatDate: Works well together in workflows
  • EditFields: Works well together in workflows
  • GetCurrentDate → SubstractFromDate → FormatDate: Common integration pattern
  • EditFields → SubstractFromDate → DownloadAsFile: Common integration pattern

Decision Guides:

General Resources: