Introduction
In this blog, I will explain to you how to generate random date between 2 years using below functions.
Function for the blog
rand
The rand function generates a random number between 2 numbers. We need to provide a minimum and maximum limit to generate a random number between those numbers.
parseDateTime
The parseDateTime function converts the string to date format.
Function to generate random date between 2 years
parseDateTime(concat(concat(concat(concat(rand(1,12),'-'),rand(1,28)),'-'),rand(1950,2010)),'MM-dd-yyyy')
rand(1,12) = for month
rand(1,28) = for day
rand(1950,2010) = from year, to year, you can change according to your requirements.