# Convert Dates to values on an X axis

I have a bunch of dates and values which I put into the DateListPlot to get a graph. However I would also like to put this information into the Fit or LeastSquares to estimate what the value would be today. So far I have this

DateListPlot[{{{1991, 4, 1}, 100}, {{1991, 4, 1}, 110}, {{1993, 6, 1},
120}, {{1994, 4, 1}, 129}, {{1996, 4, 10}, 130}, {{1999, 2, 2},
140}, {{2004, 4, 6}, 150}, {{1999, 8, 22}, 155}, {{2003, 4, 1},
160}, {{2005, 5, 9}, 200}, {{2003, 12, 3}, 174}, {{2005, 11, 4},
193}, {{2012, 7, 1}, 212}, {{2009, 12, 12}, 232}}]


The output is a graph of course but I had hoped I could do something like

Coordinates=DateListPlot[...]

And then send that into Fit or something. The problem here is converting the date values into some numbers which could be used with Fit. For example I could convert every day since April 1st 1991 into the new x value but that isn't really an elegant solution. What would be the best way to do this?

• 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. Apr 10 '15 at 14:23
• Alright I will do as best as I can but I am really new to Mathematica. Apr 10 '15 at 14:25

See AbsoluteTime...

e.g. AbsoluteTime[{1999,1,1}] returns the number of seconds from 1st Jan 1970 to that date.

In full...

Fit[{AbsoluteTime[#1] - AbsoluteTime[{1991, 4, 1}], #2} & @@@ {{{1991,
4, 1}, 100}, {{1991, 4, 1}, 110}, {{1993, 6, 1},
120}, {{1994, 4, 1}, 129}, {{1996, 4, 10}, 130}, {{1999, 2, 2},
140}, {{2004, 4, 6}, 150}, {{1999, 8, 22}, 155}, {{2003, 4, 1},
160}, {{2005, 5, 9}, 200}, {{2003, 12, 3}, 174}, {{2005, 11, 4},
193}, {{2012, 7, 1}, 212}, {{2009, 12, 12}, 232}}, {1, x}, x]

• Yes with this I could simply plot both the coordinates and this graph, thanks. Apr 10 '15 at 14:14
• no need to subtract off the initial time here, if you remove that then you can do Plot[fit, {x, AbsoluteTime[{1991, 4, 1}], AbsoluteTime[{2009, 12, 12}]}] which can be directly combined with the DateListPlot Apr 10 '15 at 16:06