I have one table which contains time periods ("start"
and "end"
) and a "type"
for every period:
table1 = {{"start", "end", "type"},
{{2013, 8, 10, 8, 5, 0.`}, {2013, 8, 10, 10, 6, 0.`}, "a"},
{{2013, 8, 10, 10, 6, 0.`}, {2013, 8, 10, 10, 50, 0.`}, "b"},
{{2013, 8, 10, 10, 50, 0.`}, {2013, 8, 10, 12, 10, 10.`}, "c"}}
Now, I have a second table which contains dates:
table2 = {"date",
{2013, 8, 10, 11, 5, 0.`},
{2013, 8, 10, 10, 15, 0.`},
{2013, 8, 10, 10, 35, 0.`},
{2013, 8, 10, 11, 10, 0.`},
{2013, 8, 10, 12, 5, 0.`}}
What I want to do now, is to test whether a date is within one of the periods and if yes in which period. The result should be a table which shows in which period the date is. For my small example, the table should look like this:
result = {{"date", "coresp. type"},
{{2013, 8, 10, 11, 5, 0.`}, "c"},
{{2013, 8, 10, 10, 15, 0.`}, "b"},
{{2013, 8, 10, 8, 5, 0.`}, "a"},
{{2013, 8, 10, 11, 10, 0.`}, "c"},
{{2013, 8, 10, 12, 5, 0.`}, "c"},
{{2013, 9, 10, 10, 10, 0.`}, "none"}}
Is there an way to create the result table automatically?
result
does not fittable2
... $\endgroup$