# Need Query form to extract Min and Max DateList values for PlotRange from a Dataset

(* SUMMARY - In a Dataset holding DateList entries, how do I extract a minimum and maximum DateList value to pass into DateListPlot's PlotRange specification? See QUESTION further below *)

(* Sample dataset. Actual dataset is much larger. My goal is to create a time series animation where the PlotRange has fixed dimensions for the X/Y axis *)

aDataSet =Dataset[{
}];


dateRange=Sort[aDataSet[[All,"aDate"]]]/@ {First,Last};


(* PlotRange for duration *)

durationRange = Sort[aDataSet[[All,"aDuration"]]]/@ {First,Last};


(* QUESTION - how should I compute dateRange such that it is a form that can be used in PlotRange for DateListPlot? Otherwise, the following will fail because the computed form of dateRange is a Dataset. DateListPlot is expecting a List whose values are the min and maximum dates for the x-axis *)

DateListPlot[aDataSet[[All,{"aDate", "aDuration"}]],Joined->False,
PlotRange->{dateRange,durationRange}]

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. Commented Apr 6, 2015 at 1:21
• Thank you for taking a moment to re-formatting my inquiry to improve its readability! Commented Apr 6, 2015 at 11:39

I think your running into trouble with those "24." as the last entry in your date list. That should be a number instead of a string.

aDataSet =Dataset[{
}];


With it as a number then the following would work.

aDataSet[All, "aDate", DateObject][{Max, Min}] // Normal


It gets All of the "aDate" values and converts them into DateObjects. The gets the Min and Max and takes it out of the dataset and into a regular list.

Hope this helps.

• BINGO -- Thank you for catching the data typo ... but more importantly, your sample code here answered my issue -- thank you! Commented Apr 6, 2015 at 11:41
• @AChaseTurner you can also use MinMax instead of {Min, Max}, if you have 10.1. Commented Apr 7, 2015 at 21:42
• Thank you -- I am using 10.1 and MinMax works for me! Commented Apr 8, 2015 at 23:57