Actions22
- Tool Actions
- Other Tool Actions
- Date Operation Actions
- Text & Formatting Actions
Date Operation → Generate Random Date
AI-generatedOverview
This node provides a variety of utility operations grouped under different resources, including date-related functions. Specifically, the "Generate Random Date" operation creates a random date between two user-specified dates. This is useful in scenarios where you need to simulate or generate test data with random timestamps within a defined range, such as generating random event dates, scheduling simulations, or creating randomized datasets for testing workflows.
For example, if you want to assign random birthdates to a list of users within a certain period, this operation can generate those dates automatically.
Properties
| Name | Meaning |
|---|---|
| Start Date | The beginning date of the range within which the random date will be generated. Required. |
| End Date | The ending date of the range within which the random date will be generated. Required. |
Both properties expect date-time inputs and define the inclusive range for the random date generation.
Output
The output JSON object for each input item includes:
startDate: The start date string provided as input.endDate: The end date string provided as input.randomDate: The generated random date in ISO 8601 format (UTC).randomDateFormatted: The generated random date formatted as a locale-specific date string using the Hebrew (Israel) locale.
Example output JSON:
{
"startDate": "2023-01-01T00:00:00.000Z",
"endDate": "2023-12-31T23:59:59.999Z",
"randomDate": "2023-07-15T10:23:45.678Z",
"randomDateFormatted": "15/7/2023"
}
The node does not output binary data.
Dependencies
- No external services or API keys are required.
- The node relies on standard JavaScript
Dateobjects and methods. - No special environment variables or n8n credentials are needed.
Troubleshooting
- Invalid date format error: If either the start or end date is not a valid date string, the node throws an error "Invalid date format". Ensure that the input dates are correctly formatted ISO strings or recognized date formats.
- Start date must be before end date: If the start date is equal to or after the end date, the node throws an error "Start date must be before end date". Make sure the start date precedes the end date.
- Empty or missing dates: Both start and end dates are required. Omitting either will cause errors.
- Timezone considerations: The random date is generated based on UTC time internally and output as ISO string. The formatted date uses the Hebrew locale for display but does not adjust timezone beyond that.