I have a list of dates in the form YYYY-MM-DD, where each element is not surrounded by quotations. How do I use Mathematica to convert that list of dates into a list of the number of days since a specific date? Here's an example:
Let's say I have the following list of dates
l={1997-05-16, 1997-05-19, 1997-05-20, 1997-05-21, 1997-05-22}
and I want a list of days since 1997-05-16 for each element in l
. So, I would want the output
{0, 3, 4, 5, 6}
I know the function DateDifference
exists, but it only takes a maximum of two elements and doesn't accept lists; plus, the values must be of the form {YYYY, MM, DD} or strings like "1997-05-19" (must have quotations).
EDIT:
Regarding the date format, these dates are coming from an imported CSV file. I tried to look for a way to make all the elements strings, i.e. insert quotations around each element in the list, but I could not find a way to do that. Is there a way to do that? I have Mathematica v9.0.1
EDIT 2:
Here is the CSV data on pastebin: https://pastebin.com/BRqwfGPi
Additionally, here is how I'm importing the date data:
datedata =
Import["CSV Data", {"Data", All, 1}];(* Imports dates from first column in CSV *)
datedata1 = Delete[datedata, 1];(* Deletes header element from list *)
Note that I replaced the actual path to the file as "CSV Data"
in Import
.
1997-05-16
is a math formula and won't survive long unless you useHold
or something. Have you seenl
after you defined it? Where do you get the input from? $\endgroup$Import[]
. Why not post the CSV on Pastebin, and then show in your question how you do the importing? $\endgroup$