Random Date Range Generator

  • Share this:

Code introduction


This function takes the start year and end year as parameters, generates a random date range, and returns two arrow objects.


Technology Stack : Arrow

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random
import arrow

def random_date_range(start_year, end_year):
    start_date = arrow.get(random.randint(start_year, end_year), 'YYYY-MM-DD')
    end_date = arrow.get(random.randint(start_year, end_year), 'YYYY-MM-DD')
    return start_date, end_date                
              
Tags: