You can download this code by clicking the button below.
This code is now available for download.
This function generates a random date between the given start date and end date. It uses the Pendulum library to handle dates.
Technology Stack : Pendulum
Code Type : Function
Code Difficulty : Intermediate
def random_date_period(start_date, end_date):
from pendulum import parse, interval
start = parse(start_date)
end = parse(end_date)
interval = interval(interval=(end.year - start.year) * 365)
random_date = start.add_days(interval.random_days())
return random_date.format('YYYY-MM-DD')