user336: I'm creating a weather station / environmental datalogger and am saving my data to a SD card Breakout. The SD card works fine but I would like to name the files I am saving on it after the date when the readings were taken.I've tryed multiple things but I can't work out how to combine the date from my RTC and put them in a file name. I've tryed this:
dataFile = SD.open(String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv",FILE_WRITE);

But this gives me an error -
char dateName[13] = {String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv"};
dataFile = SD.open(dateName,FILE_WRITE);

But this gives me this error:
 cannot convert 'StringSumHelper' to 'char' in initialization

Help! How do I do this? 

user65: In your second case, you need to break the initialization into two lines and use toCharArray() as shown:
char dateName[13];
String(String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv").toCharArray(dateName, 13);

Then, you can move ahead with opening the file.
The problem you are seeing is quite literally what the error message says. An initialization of a character array requires a character array. It cannot be initialised with a string object.

user42697: //////////////////////////////////////////////////////////////
String filename = String(now.month()) + "-" + String(now.year()) + ".csv";

char str[16] = {0};

filename.toCharArray(str, 16);

File dataFile = SD.open(str, FILE_WRITE);

//////////////////////////////////////////////////////////////

user89: Is this based on the SDFat library?
Then you have to live with short 8.3 filenames for the moment.

user42: EDIT: As noted by Klaus Warzecha, the SD library may only support 8.3 format filenames (i.e. 8 characters for the name, 3 characters for the extension). The solution may in fact be to ensure that the years is only 2 digits, resulting in names like: 20-12-14.csv

From what I can see in the SD library code, the open() method isn't designed to accept a String object as a parameter. It only wants a plain old C-style string (which means a char array). That explains why your first example doesn't work -- it's trying to pass a String object.
The second example unfortunately is invalid C++. You simply can't initialise an array like that. What you want to do instead is to build the String object, then extract the characters out using String::toCharArray().
Something like this should work:
String filename = String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv";
char str[16] = {0};
filename.toCharArray(str, 16);
dataFile = SD.open(str, FILE_WRITE);

I'm not sure what your now.year() returns; i.e. if that's a 2 digit or 4 digit year. I've assumed 4 digits, so I've made the char array big enough for 15 characters in total, plus an extra null terminator (which is essential for C-style strings).

336: <p>I'm creating a weather station / environmental datalogger and am saving my data to a SD card Breakout. The SD card works fine but I would like to name the files I am saving on it after the date when the readings were taken.I've tryed multiple things but I can't work out how to combine the date from my RTC and put them in a file name. I've tryed this:</p>

<pre><code>dataFile = SD.open(String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv",FILE_WRITE);
</code></pre>

<p>But this gives me an error -</p>

<pre><code>char dateName[13] = {String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv"};
dataFile = SD.open(dateName,FILE_WRITE);
</code></pre>

<p>But this gives me this error:</p>

<pre><code> cannot convert 'StringSumHelper' to 'char' in initialization
</code></pre>

<p>Help! How do I do this? </p>
 65: <p>In your second case, you need to break the initialization into two lines and use <a href="http://arduino.cc/en/Reference/StringToCharArray" rel="nofollow">toCharArray()</a> as shown:</p>

<pre class="lang-cpp prettyprint-override"><code>char dateName[13];
String(String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv").toCharArray(dateName, 13);
</code></pre>

<p>Then, you can move ahead with opening the file.</p>

<p>The problem you are seeing is quite literally what the error message says. An initialization of a character array requires a character array. It cannot be initialised with a string object.</p>
 42697: <p>//////////////////////////////////////////////////////////////</p>

<pre><code>String filename = String(now.month()) + "-" + String(now.year()) + ".csv";

char str[16] = {0};

filename.toCharArray(str, 16);

File dataFile = SD.open(str, FILE_WRITE);
</code></pre>

<p>//////////////////////////////////////////////////////////////</p>
 89: <p>Is this based on the <a href="http://code.google.com/p/sdfatlib/" rel="nofollow">SDFat</a> library?</p>

<p>Then you have to live with short 8.3 filenames for the moment.</p>
 42: <p><em>EDIT: As noted by Klaus Warzecha, the SD library may only support 8.3 format filenames (i.e. 8 characters for the name, 3 characters for the extension). The solution may in fact be to ensure that the years is only 2 digits, resulting in names like: <code>20-12-14.csv</code></em></p>

<hr>

<p>From what I can see in the SD library code, the <code>open()</code> method isn't designed to accept a <code>String</code> object as a parameter. It only wants a plain old <a href="http://arduino.cc/en/Reference/String" rel="nofollow">C-style string</a> (which means a <code>char</code> array). That explains why your first example doesn't work -- it's trying to pass a <code>String</code> object.</p>

<p>The second example unfortunately is invalid C++. You simply can't initialise an array like that. What you want to do instead is to build the <code>String</code> object, then extract the characters out using <code>String::toCharArray()</code>.</p>

<p>Something like this should work:</p>

<pre><code>String filename = String(now.day()) + "-" + String(now.month()) + "-" + String(now.year()) + ".csv";
char str[16] = {0};
filename.toCharArray(str, 16);
dataFile = SD.open(str, FILE_WRITE);
</code></pre>

<p>I'm not sure what your <code>now.year()</code> returns; i.e. if that's a 2 digit or 4 digit year. I've assumed 4 digits, so I've made the <code>char</code> array big enough for 15 characters in total, plus an extra null terminator (which is essential for C-style strings).</p>
