Function Repository Resource:

RandomDate

Source Notebook

Sample random date lists

Contributed by: Michael Sollami

ResourceFunction["RandomDate"][]

gives a random date in the current year.

ResourceFunction["RandomDate"][n]

gives n random dates in the current year.

ResourceFunction["RandomDate"][{low, high}]

generates a random date between low and high.

ResourceFunction["RandomDate"][{low,high},n]

generates n random dates in the given range.

Details and Options

ResourceFunction["RandomDate"] date ranges should be given as lists.
ResourceFunction["RandomDate"] returns lists of DateObject expressions.

Examples

Basic Examples (5) 

Generate some random dates:

In[1]:=
ResourceFunction["RandomDate"][4]
Out[1]=

Generate a tensor of random dates:

In[2]:=
ResourceFunction["RandomDate"][{1900, 2000}, {3, 2}] // MatrixForm
Out[2]=

Generate random dates between days:

In[3]:=
DateHistogram@
 ResourceFunction["RandomDate"][{Yesterday, Tomorrow}, 10^3]
Out[3]=

Plot lists of random dates:

In[4]:=
TimelinePlot[ResourceFunction["RandomDate"][{2000, 2008}, {4, 10}]]
Out[4]=

Make a timeline plot of random dates in the first quarter of the year:

In[5]:=
TimelinePlot[
 ResourceFunction["RandomDate"][{{2020, 1}, {2020, 6, 31}}, 100], PlotRange -> {"Jan 1, 2020", "Dec 31, 2020"}]
Out[5]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 07 April 2020

Related Resources

License Information