I am trying to implement Table with a DateObject with the goal to obtain a series of increasing dates:
Table[
DateObject[Today],
{DateRange[Today, DatePlus[Today, Quantity[5, "Days"]]]}
]
The problem is that I obtain the same DateObject instead of increasing days:
{DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.],
DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.],
DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.],
DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.],
DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.],
DateObject[{2020, 12, 29}, "Day", "Gregorian", 1.]}
How can I obtain a series of increasing days with Table?
DateRange[Today, DatePlus[Today, Quantity[5, "Days"]]], explicitTableis not needed. – Rohit Namjoshi Dec 29 '20 at 14:52Tablebecause later in the code i need to imlement a function, which is dependent on aDateObjectlike this:Table[p1[DateObject[{2020,12,n}]],{n,1,20}]and i would like toimplement this automatically with a 'Today' Any idea how this can be done withTable? – Pinco Dec 29 '20 at 15:29p1 /@ DateRange[Today, Today + Quantity[20, "Days"]]do? OrTable[p1[i], {i, Today, Today + Quantity[20, "Days"], Quantity[1, "Days"]}]? – MarcoB Dec 29 '20 at 15:38p1which requires only one argument asDateObject, but what if you need to map to another functionp2which needs a second argument (a number) ? i tried the following:testdata1 = p2 /@ {DateRange[Today, Today + Quantity[500, "Days"]], 70.}? i get the following error when trying on p2 which requires a second argument:PredictorFunction::mlbftlgth2: Example DateObject[{2020,12,29},Day,Gregorian,1.] should have 2 features instead of 4.do you know how to implement p2 with a second argument? – Pinco Dec 29 '20 at 16:48p2[#, 70]& /@ DateRange[...]. You might want to read up on function construction a bit (e.g. Pure functions,Function(i.e.&),Slot(i.e.#), andMap(/@)). See also this FAQ on all those funny characters in MMA. – MarcoB Dec 29 '20 at 17:36testdata1 = p2[#, 70] & /@ DateRange[Today, Today + Quantity[500, "Days"]];) but i still get an error, the following:PredictorFunction::mlbddataev: The data being evaluated is not formatted correctly.Any clue what is still wrong ? – Pinco Dec 29 '20 at 17:51PredictorFunctionand it's hard to say without knowing more about your actual code – MarcoB Dec 29 '20 at 19:10testdata1 = p2[{#, 70}] & /@ DateRange[Today, Today + Quantity[365, "Days"]];now it works. Thanks again – Pinco Dec 30 '20 at 14:14