With Mathematica 9.0 for Mac OS X x86 (64-bit) (January 24, 2013) one could use
DateRange[{2000}, {2010}, "Year"]
to achive
{{2000}, {2001}, {2002}, {2003}, {2004}, {2005}, {2006}, {2007}, {2008}, {2009}, {2010}}
or
leapyears = Select[DateRange[{2000}, {2020}, "Year"], LeapYearQ[#] &]
with the result
{{2000}, {2004}, {2008}, {2012}, {2016}, {2020}}
With Mathematica 10.0 for Mac OS X x86 (64-bit) (June 29, 2014)
DateRange[{2000}, {2010}, "Year"]
one will get
{{2000, 1, 1}, {2001, 1, 1}, {2002, 1, 1}, {2003, 1, 1}, {2004, 1,
1}, {2005, 1, 1}, {2006, 1, 1}, {2007, 1, 1}, {2008, 1, 1}, {2009,
1, 1}, {2010, 1, 1}}
leapyears = Select[DateRange[{2000}, {2020}, "Year"], LeapYearQ[#] &]
{{2000, 1, 1}, {2004, 1, 1}, {2008, 1, 1}, {2012, 1, 1}, {2016, 1,
1}, {2020, 1, 1}}
The Function DateObject
does not clear a bean to me
DateRange[DateObject[{2000}], DateObject[{2012}], "Year"]
So, how can i get rid of the additional month, day
information on V10, i.e. using leapyears
and DateObject
returning Year
only?
Answer
I would use:
DateRange[{2000}, {2010}, "Year"][[All, {1}]]
{{2000}, {2001}, {2002}, {2003}, {2004}, {2005}, {2006}, {2007}, {2008}, {2009}, {2010}}
% ~Select~ LeapYearQ
{{2000}, {2004}, {2008}}
Note the {1}
in the Part
parameters; see Head and everything except Head?
Comments
Post a Comment