Description
The FlexibleDateRangeGen Generator randomly generates dates given a startDate, a startRange, and an endRange. A random number is generated between the startDate and endDate, and the result equals the startDate plus or minus the value generated.
In This Article
- Receiver Parameters
- How do the startRange and endRange Parameters Work?
- Example 1 - Range of 0 to 4 with Year Increasing by 10 for each Record in Range
- Example 2 - Range of -5 to 0 with Year Decreasing by 1 for each Record in Range
- Example 3 - Range from -6 to 6 with Hour Decreasing by 2 for Each Record in Range
- Example 4 - Range of 1 to 8 with Hour Increasing by 6 for each Record in Range
- Example 5 - Year Jumps by 1 every 5 Records
Receiver Parameters
The following parameters may be configured for the FlexibleDateRangeGen Generator. Items with an asterisk* are required.
- format* - Defines the date format for the start date and the generated result. Default value is yyyy-MM-dd. Additional examples:
- MM/dd/yy = 12/26/99
- MM-dd-yy = 04-26-1995
- yyyy-MM-dd HH:mm:ss = 2017-12-30 18:52:10
- startDate - Defines the start date. If left empty, it will equal the current date.
- startRange* - Defines an integer value for how far forward or backward to begin from the start date.
- endRange* - Defines an integer value for how far forward or backward to end from the start date.
- iniitalJump* - Defines how much to jump before the first iteration (Year, Month, Week, Day, or Hour).
- jumpAmount* - Defines how much to jump by (Year, Month, Week, Day, or Hour).
- nextBy* - Defines how the start date will be incremented or decremented by the generated value (Year, Month, Day, Hour, Minute, Second, or Millisecond).
- waitAmount* - Defines the number of iterations the Generator should wait (repeat) before calculating the next date.
- randomize* - Defines if the next value will be sequential or random within the startRange and endRange.
- randomizeMonthDay* - Defines if the Month and Day should be random if neither is set as the nextBy value.
- seed - Using the seed will ensure that the same random data is generated each time data is generated.
- exclude - Defines what all dates should be excluded based on the nextBy Attribute parameter. The input should be a comma-separated Integer value.
Example 1: If nextBy is the day, then exclude can have values in the range of 1-31.
Example 2: If nextBy is the month, then exclude can have values in the range of 1-12.
The exclude value must be within the range of the selected nextBy Attribute parameter value.
How do the startRange and endRange Parameters Work?
The startRange and endRange parameters define a range in which a selected value within the startDate parameter (Month, Day, Year, Hour, Seconds, or Milliseconds) will increase or decrease. Values for both of these parameters can be:
- Negative - Represents a decrease (e.g., -1, -5)
- Positive - Represents an increase (e.g., 1, 5)
- Zero - Reprenses no change. Starts at the entered value for the startDate parameter and then increases or decreases based on the defined range (e.g., 0).
Example: When the values are set as shown below, it represents a range of 4, which means that the range will start over after 4 records and repeat the pattern until all test data is generated.
Note: An error will occur if the startRange is more than the endRange. An example is shown below:
The nextyBy parameter determines which value within the startDate parameter will be increased or decreased. For example, if "Year" is selected, the year will increase or decrease based on the entered range and the jumpAmount parameter.
The jumpAmount parameter determines the amount the value jumps for each record within the defined range. In the example below, each year will change by 10 (e.g., 1970, 1980, 1990, 2000).
Example 1 - Range of 0 to 4 with Year Increasing by 10 for each Record in Range
In this example, the first record will use the entered startDate of 01-01-1970, and the year will increase by 10 for the next three records (in the range). Once the end range is met, the next record will start over with a date of 01-01-1970.
For this example, the following parameters have been set
- startRange = Set to "0" to not go forward or backward from the startDate parameter value.
- endRange= Set to "4", which means that the range will end at four records and then start over for the next record with 01-01-1970. Example:
- Record 1 - 01-01-1970
- Record 2 - 01-01-1980
- Record 3 - 01-01-1990
- Record 4 - 01-01-2000
- Record 5 - Starts again at 01-01-1970
- initialJump = Set to "0", which means that no jump will occur, and the first record will have the startDate parameter value (i.e., 01-01-1970).
- jumpAmount = Set to "10", which means that the value will jump by 10 for each new record until the endRange parameter value is reached.
- nextBy = Set to "Year" to increase the year by the entered jumpAmount.
- randomize = Set to "false" to generate values sequentially.
- randomizeMonthDay = Set to "None" to easily show how range impacts the year in this example.
Sample Output
Note: The randomizeMonthDay parameter could be set to "MonthAndDay, MonthOnly, or DayOnly" to have random months and days with the increasing year in this example. Below it has been set to "MonthAndDay".
Just as above, the range is 0 to 4. A random month and day are used for the next three consecutive records before starting over at 01-01-1970.
Example 2 - Range of -5 to 0 with Year Decreasing by 1 for each Record in Range
In this example, the startDate will be formatted as MM-dd-yyyy and entered as 01-01-1970.
For this example, the following parameters have been set
- startRange = Set to "-5", which means the first value will start 5 years before the entered startDate parameter's year value of 1970. The year for the first record will be 1965.
- endRange= Set to "0", which means the year will decrease for the next four records. On the 6th record, it will start over with 01-01-1965. Example:
- Record 1 - 01-01-1965
- Record 2 - 01-01-1964
- Record 3 - 01-01-1963
- Record 4 - 01-01-1962
- Record 5 - 01-01-1961
- Record 6 - Starts over with 01-01-1965
- nextBy = Set to "Year", which means the year will be modified for each record based on the configured parameters.
- jumpBy = Set to "1", which means the year will increase by 1 for each consecutive record within the range.
Sample Output
Example 3 - Range from -6 to 6 with Hour Decreasing by 2 for Each Record in Range
In this example, the startDate will be formatted as yyyy-MM-dd HH:mm:ss and be entered as 1970-01-01 00:00:00.
For this example, the following parameters have been set
- startRange = Set to "-6", which means the first value will start 6 hours back from the startDate parameter's hour value of 00. The hour for the first record will be 18 (e.g., 18:00:00).
- endRange= Set to "6", which means that the hour will decrease for the next 12 records. On the 13th record, it will start over at 00:00:00. Example:
- Record 1 - 1969-12-31 18:00:00
- Record 2 - 1969-12-31 16:00:00
- Record 3 - 1969-12-31 14:00:00
- Record 4 - 1969-12-31 12:00:00
- Record 5 - 1969-12-31 10:00:00
- Record 6 - 1969-12-31 08:00:00
- Record 7 - 1969-12-31 06:00:00
- Record 8 - 1969-12-31 04:00:00
- Record 9 - 1969-12-31 02:00:00
- Record 10 - 1969-12-31 00:00:00
- Record 11 - 1969-12-30 22:00:00
- Record 12 - 1969-12-30 20:00:00
- Record 13 - Start over at 1969-12-31 18:00:00
- nextBy = Set to "Hour", which means the hour value will be modified for each record based on the configured parameters.
- jumpBy = Set to "2", which means the year will decrease by 2 for each consecutive record within the defined range.
Sample Output
Please note that since the first record decreases by 6 hours, the date is 1969-12-31 and continues to decrease based on the time value until the endRange is reached.
Example 4 - Range of 1 to 8 with Hour Increasing by 6 for each Record in Range
In this example, the startDate will be formatted as yyyy-MM-dd HH:mm:ss and be entered as 1970-01-01 00:00:00.
For this example, the following parameters have been set
- startRange = Set to "1", which means the first value will increase by 1 hour from the startDate parameter's hour value of 00. The hour for the first record will be 01 (e.g., 01:00:00).
- endRange= Set to "8", which means that the hour will increase for the next 7 records. On the 8th record, it will start over at 00:00:00. Example:
- Record 1 - 1970-01-01 01:00:00
- Record 2 - 1970-01-01 07:00:00
- Record 3 - 1970-01-01 13:00:00
- Record 4 - 1970-01-01 19:00:00
- Record 5 - 1970-01-02 01:00:00
- Record 6 - 1970-01-02 07:00:00
- Record 7 - 1970-01-02 13:00:00
- Record 8 - Starts over with 1970-01-01 01:00:00
- nextBy = Set to "Hour", which means the hour value will be modified for each record based on the configured parameters.
- jumpBy = Set to "6", which means the hour will increase by 6 for each consecutive record within the defined range.
Sample Output
Example 5 - Year Jumps by 1 every 5 Records
For this example, the Domain will generate 100 records.
The startDate will be formatted as MM-dd-yyyy and entered as 01-01-1970.
For this example, the following parameters have been set:
- startRange = Set to "1", which means the first value will be one year later than the startDate parameter's year value (e.g., 1971).
- endRange= Set to "100", which means that the range will end when all data has been generated.
- nextBy = Set to "Year", which means the year value will be modified for each record based on the configured parameters.
- jumpBy = Set to "1", which means the year will increase by 1.
- waitAmount = Set to "10", which means that the year will jump by 1 every 10 iterations.
- randomize = Set to "false", which means the values will be generated sequentially.
- randomizeMonthDay = Set to "MonthAndDay", which means a random Month and Day will be used.
Sample Output
For every 5 records, the year increases by one. The Month and Day are random and remain the same for each set of 5 records. Please note that the entire file is not shown below - only portions are displayed.