Downloading a sheet as a CSV converts the dates to MM/DD/YY

I'm downloading a sheet as a CSV, manipulating some data, and creating new spreadsheets out of that data.

Everything works until I try to upload a date that I'm downloading from smartsheets.

In the smartsheet the date looks like this:

However when I use the node SDK I get this:

var options = {
   id: spreadSheetID
};
    
smartsheet.sheets.getSheetAsCSV(options).then(result => {
 console.log(result);
}

"Available_Date"
"04/05/22"
"04/12/22"

I know that I need to upload the dates in the YYYY-MM-DD format. So why does the API return them in the wrong format when exporting as a CSV?

Best Answer

  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓

    Hi @charlie_wt

    The format of the date that you're seeing in the sheet in Smartsheet is a display value specific to that sheet, however the underlying data will be based on your account's Personal Settings under Regional Preferences.

    This is the date format that the API will pull when exporting a sheet for date columns, regardless of the sheet-specific display formatting. Exporting the sheet directly from the UI will provide the same experience: dates are exported in the format set in your Regional Preferences.

    Cheers,

    Genevieve

Answers

  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓

    Hi @charlie_wt

    The format of the date that you're seeing in the sheet in Smartsheet is a display value specific to that sheet, however the underlying data will be based on your account's Personal Settings under Regional Preferences.

    This is the date format that the API will pull when exporting a sheet for date columns, regardless of the sheet-specific display formatting. Exporting the sheet directly from the UI will provide the same experience: dates are exported in the format set in your Regional Preferences.

    Cheers,

    Genevieve

  • This is very helpful, in the future though I think there should be an option to pass in the format of the dates so that they can be re-uploaded easier. It makes it hard to share scripts if you can't predict the date format either.