Random Date Generator Between Two Dates

  • Share this:

Code introduction


This function takes two date strings as arguments and returns a random date between these two dates.


Technology Stack : Delorean

Code Type : Function

Code Difficulty : Intermediate


                
                    
def random_date_between_dates(start_date, end_date):
    from delorean import Delorean
    
    # Create a Delorean instance with the start date
    start_delorean = Delorean(date=start_date)
    # Create a Delorean instance with the end date
    end_delorean = Delorean(date=end_date)
    # Generate a random date between the start and end dates
    random_date = start_delorean.random_between(end_delorean)
    return random_date.date
                    
              
Tags: