Q:

Combining Strings into a datestamp

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?  

A:

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).