Randomise Date Column

This is a useful statement for when you need help randomizing your date data for testing purposes. In this case, I’m assuming you’ve inserted a certain amount of test data into your table but it’s all showing the same date.

First of all: temporarily disable any triggers that you have that will affect this table.

Modify this statement to fit your needs:


This will generate random dates between the two date parameters you’ve set. One thing to note though is that it isn’t changing the HH:MM:SS of the data, only the day. If you want those randomized as well you’d need to change the truncate value to whatever you needed it to be.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s