Sequential dates (no repeating)

Hi there. I need to generate some dummy data where I have an array of operations with dates from and to. I its easy to create random dates from and to that is always after from, but I need to find a way that the next dataset has a FROM that is at least one day after the previous TO.

Any ideas?

{
			"from": "2024-04-24",
			"to": "2024-04-29",
			"operations": [...]
		},
		{
			"from": "2024-04-30",
			"to": "2024-05-12",
			"operations": [...]
}
			]
		},

Hi garfolino,

This looked interesting, so I took a shot.

Basic algorithm: have a ‘from’ date that increments in units of time larger than 1 (I picked 10 for my example), while the ‘to’ date starts from the ‘from’ date + a number of days less than that unit of time.

Here is a working example: Mockaroo - Random Data Generator and API Mocking Tool | JSON / CSV / SQL / Excel

There are a number of ways to improve this (for example, using now() - 200 (or more) days for the starter date, randomizing the # of days for the block (10) using a Formula calculation random(min, max) and then calculating the __numdaysopen to be 2 less than that, etc.), but I’ll leave that as an exercise for the reader - this should be enough to get you started…assuming you still need it.

HTH,
Paul

1 Like

Hi Paul, this is amazing, thank you so much! :slight_smile:

So anything with __ is just there to help build what we want?

Yep.

If a field starts with two underscores, Mockaroo will generate it, and its value will be accessible to other field criteria after it, but it will not be shown in the output.