I have written a C# program that pulls data from SmartSheet then inserts the data into a SQL Database. Everything is working perfectly except for dates. I have searched this site plus others on how to pull the date information in a format that can be loaded into the SQL database. I have an outstanding question to the API group at SmartSheet. The contact person at SmartSheet admitted that they did not have documentation on how to perform this function. There is documentation on how to format the data to insert into a sheet, but not how to format the data in pulling a date format from Smartsheet. Can anybody help? Thanks.
c# Smartsheet API Display Date
451 views Asked by FRR AtThere are 4 answers
On
Have you already read the Dates and Times section of the Smartsheet API docs? Here's the relevant excerpt:
The Smartsheet API returns all dates and times in the UTC time zone in ISO-8601 format, that is, YYYY-MM-DDTHH:MM:SSZ
There is also a query parameter (numericDates=true) you can pass with your request if you want to receive the date in Unix Epoch Time.
Is there a reason you don't want to store the ISO-8601 date in your SQL database? That format contains all the information you might need in the future. You could also apply any date formatting logic you want either before or after you store the date.
On
Taylor's answer is correct. You can pass the numericDates query parameter to get a numeric epoch value. That said, if you prefer to take the ISO-8601 string, there are C# ways to convert that to other formats. You could then convert into whatever requirements your SQL database has.
var convertedTime = DateTime.ParseExact(cellDateValueString, "YYYY-MM-DDTHH:MM:SSZ", CultureInfo.InvariantCulture);
On
I am new to c# and .net, so I supposed it was just me. But here is the answer.
statusCellTask = getCellByColumnName(row, "Start");
var varStart = statusCellTask.Value;
if (varStart is null
{ command.Parameters.AddWithValue("@sqlStart", ""); }
else
{
string Start = varStart.ToString();
command.Parameters.AddWithValue("@sqlStart", Start);
}
I hope that this helps someone with what I have struggled with.
I know this is old, but I think the question being asked is how to extract date data from the SmartSheet API. From what I had to work out it has to do with the PaginatedResult being configured.
Example: