Date and time field fields

  • Release version: Australia
  • Updated May 7, 2026
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Date and time field fields

    Date and time fields in ServiceNow CPQ are essential for managing contract terms and auditing quote activities. They enable accurate calculation of contract durations (including start, end, renewal, and subscription dates) and track key quote events such as creation, pricing updates, and approvals. Proper handling of blank or null date values is crucial to maintain data accuracy and completeness, with system defaults or error flags recommended to address missing dates.

    Show full answer Show less

    Date and time formats

    ServiceNow Quote Experience supports two main date/time formats:

    • Date only: Uses the pattern YYYY-MM-DD (e.g., 2024-11-07), which is time-zone agnostic.
    • Date and time: Uses ISO 8601 format YYYY-MM-DDTHH:MM:SS stored in UTC (e.g., 2024-10-22T14:30:00Z).

    Administrators can configure fields to show either just the date (type":"Date) or both date and time (type":"DateTime).

    Handling null and blank dates in scripts

    Blank or null date values are treated as false in comparisons unless directly compared to another blank value. By default, date fields are null unless a default value is set. For example:

    • date123 = "" evaluates to true when date123 is blank.
    • date123 != "" evaluates to false for a blank date.

    Supported comparison operators

    The following operators can be used in rules and scripts for date/time comparisons, but any comparison where one operand is blank or null results in false (except equality of two blanks):

    • <, <=, >, >=: false if either date is blank/null.
    • =: true only if both dates are blank.
    • !=: false if either operand is blank/null.

    Aggregate functions for date fields

    In determination rule scripts, the following aggregate functions are supported for date fields:

    • Max: Returns the latest date in the set.
    • Min: Returns the earliest date in the set.
    • Count: Counts non-empty date values.

    Functions like Sum and Avg are not applicable to date fields and may cause errors.

    Example: Calculating subscription terms

    The documentation provides a script example that calculates the difference between a start date and an end date in months and days, useful for populating subscription term fields in quote transactions. This script can be used in determination rule actions to derive summary values from date inputs.

    Practical implications for ServiceNow customers

    • Use date/time fields to automate and accurately calculate contract durations and renewal timelines in your quoting process.
    • Ensure blank or null date fields are handled explicitly to avoid inaccurate term calculations or incomplete audit data.
    • Leverage supported aggregate functions in scripts to summarize date information across transactions effectively.
    • Configure date/time display types to match your quoting interface requirements.
    • Use the provided scripting patterns to implement custom date calculations within your rules.

    Reference for how date and time fields behave in ServiceNow CPQ ServiceNow Quote Experience rules and scripts, including comparison operators, null handling, and supported aggregate functions.

    Date and time fields in quoting

    Date and time fields in ServiceNow CPQ serve two primary purposes in a quoting context.

    Term calculations
    Calculate contract terms, start and end dates, renewal dates, and subscription lengths. Blank or null date values can affect term accuracy — use system defaults such as the current date, or flag missing values using error messages in rules.
    Audit events
    Track activities such as quote creation, pricing changes, and approval events. Missing dates indicate incomplete data and should be flagged for review.

    Date and time formats

    ServiceNow Quote Experience supports the following date and time formats.

    Table 1. Date and time field formats
    Format type Format pattern Example
    Date only YYYY-MM-DD 2024-11-07
    Date and time YYYY-MM-DDTHH:MM:SS 2024-10-22T14:30:00
    UTC (stored format) YYYY-MM-DDTHH:MM:SSZ 2024-10-22T14:30:00Z

    Date-only fields are time-zone agnostic. All date and time values are stored in Coordinated Universal Time (UTC) to avoid time-zone discrepancies. Administrators can choose whether to include the time component when configuring a date/time field.

    In the ServiceNow Quote Experience layout, the field type value that controls display behavior is:

    • "type":"Date" — displays only the date component.
    • "type":"DateTime" — displays both date and time components.

    Null and blank date behavior in scripts

    Blank and null date values follow specific comparison rules in ServiceNow Quote Experience scripts and rule conditions.

    • Blank/null dates compare as false unless compared directly to another blank value.
    • The default value of a date field is empty (null) unless a default is specified in the field configuration.

    The following examples show blank date comparison outcomes.

    Table 2. Blank date comparison examples
    Expression Result Explanation
    date123 = "" true A blank date compared to a blank string evaluates to true.
    date123 != "" false A blank date compared as not-equal to blank evaluates to false.

    Supported comparison operators

    The following comparison operators are supported for date and time field values in rule conditions and scripts.

    Table 3. Date comparison operators
    Operator Behavior
    < Less than. Always evaluates to false when either operand is blank or null.
    <= Less than or equal to. Always evaluates to false when either operand is blank or null.
    > Greater than. Always evaluates to false when either operand is blank or null.
    >= Greater than or equal to. Always evaluates to false when either operand is blank or null.
    = Equal to. Evaluates to true only when both operands are blank.
    != Not equal to. Evaluates to false when either operand is blank or null.

    Aggregate functions for date fields

    The following aggregate functions are supported for date field values. Use these in determination rule scripts to calculate date values across transaction lines.

    Table 4. Supported aggregate functions for date fields
    Function Behavior Notes
    Max Returns the latest date in the set. Supported.
    Min Returns the earliest date in the set. Supported.
    Count Counts non-empty date values in the set. Supported.
    Sum Not applicable to date values. Not recommended — may trigger compile-time errors.
    Avg Not applicable to date values. Not recommended — may trigger compile-time errors.

    Date calculation script example

    The following script calculates the difference between a start date and an end date in months and days, and stores the result in a subscription term field. Use this pattern in a determination rule action to populate a summary field from two date inputs.

    // Calculates the difference between start and end dates in months and
    // days. Stores the result in Subscription Term (Months).
    
    var yearsDiff =
      txn.custom.endDate.getFullYear() - txn.custom.startDate.getFullYear();
    var monthsDiff =
      txn.custom.endDate.getMonth() - txn.custom.startDate.getMonth();
    var totalMonths = yearsDiff * 12 + monthsDiff;
    
    var startDay = txn.custom.startDate.getDate();
    var endDay = txn.custom.endDate.getDate();
    var daysInMonth = new Date(
      txn.custom.endDate.getFullYear(),
      txn.custom.endDate.getMonth() + 1,
      0
    ).getDate();
    var dayFraction = (endDay - startDay + 1) / daysInMonth;
    
    totalMonths += dayFraction;
    return Math.floor(totalMonths * 1000) / 1000;