How to extract date from SQLDateTime object in Mathematica

I am trying to plot a time series with DateListPlot. I want to pass it the time series that I get from the SQL database. When I get time series, the list consists of SQLDateTimeentries that I DateListPlotdo not understand.

In[24]:= t=SQLExecute[conn, "select timestamp,value from timeseries order by timestamp asc"]

Out[24]={{SQLDateTime[{2010,1,1}],12.3},{SQLDateTime[{2010,1,2}],12.51}}

Does not work: In[25]:= DateListPlot[t]

DateListPlotrequires a Date tuple and does not understand SQLDateTime. What can I do?

+5
source share
1 answer

Answer:

In[1]:= SQLDateTime[{2001, 5, 7}][[1]]
Out[1]:= {2001,5,7}

Mathematica thinks of everything very similar internally. What you see as {1, 2, 3}, in fact List[1,2,3]. The Part function (denoted by [[...]]) works exactly the same for any function, and not just List.

:

{#[[1,1]],#[[2]]}& /@ SQLExecute[...]
+7

All Articles