I am working on an application that deals with loading some SAS datasets into SQL using C#. I use the SAS OLE DB Adapter to load the SAS dataset into C# data table and its working. However, the datevalues which is stored as string datatype in the SAS file is getting loaded as 10 digit number and stored as string format in the data table.
Hence, I tried to convert them to datetime however I am getting only the date value and time value is 00:00:00 for all the records. The source has the date and time values for each record. Below is my code that I use to convert the string to datetime string.
public string ComputeDate(string sSourceData)
{
string sProcessedDate = string.Empty;
int iDateValue = ((Convert.ToInt32(sSourceData) / 86400) + 21916);
Double dDate = Convert.ToInt32(iDateValue);
DateTime dtDateValue = DateTime.FromOADate(dDate);
sProcessedDate = dtDateValue.ToString();
return sProcessedDate;
}
The source data sample and the data that is getting loaded in the data table is below
The output after converting the OADate is below
It would be great if someone can help me out in providing me an solution for getting the output along with original time value provided in the source.
Thanks in advance.