AddDateTimeWithFields adds specified values to a DateTime and returns a new DateTime value. Rather than adding two DateTimes together (like the plain AddDateTime action), this one lets you specify individual calendar/time field offsets to apply to a base DateTime:
| Property | Type | Description |
|---|---|---|
| DateTime | DateTime | The source DateTime value to which the specified field values will be added. This is the base timestamp that the action operates on. Format: YYYY-MM-DDThh:mm:ss |
| Year | Number | The number of years to add to the DateTime value. Use a positive integer to move forward in time, or a negative integer to move backward. |
| MonthOfYear | Number | The month of the year, from 1 to 12. |
| DayOfMonth | Number | The day of the month, from 1 to 31. |
| HourOfDay | Number | The hour of the day, from 0 to 23. |
| MinuteOfHour | Number | The minute of the hour, from 0 to 59. |
| Seconds | Number | The second of the minute, from 0 to 59. |
Importantly, this action replaces the older AddDays and AddHours actions, thus it is the modern, consolidated way to do date math by field, and you'll likely see it referenced instead of those two legacy actions in newer Rulesets.
Use case
A very common EDI/B2B pattern: calculating a due date by adding a number of days to an invoice date, or computing an expiration/cutoff time by adding hours to a timestamp; for example, "this purchase order is valid for 30 days from the order date" or "this quote expires 24 hours after issuance."
Example
Suppose you're processing an inbound invoice and need to calculate a payment Due Date that is 30 days after the Invoice Date (Net-30 terms):
DueDate = AddDateTimeWithFields(
DateTime = InvoiceDate,
DayOfMonth = 30
)(leaving Year, MonthOfYear, HourOfDay, MinuteOfHour, and Seconds at 0/null)
Or, for a quote that expires 24 hours after generation:
ExpirationDateTime = AddDateTimeWithFields(
DateTime = QuoteCreatedDateTime,
HourOfDay = 24
)In a Ruleset, you'd typically drag the source InvoiceDate node into the DateTime input, hard-code or map the "30" into DayOfMonth, and write the action's output to the target's DueDate field.
Comments
0 comments
Please sign in to leave a comment.