在表格中,any1是否知道如何选择指定行并在指定列中取出时间数据,然后将数据放入TimeSpan中?
DataRow[] selectIDRow = RetailCamDataSet1.Tables["smBranchWorkingDayInfo"].Select("ID=" + ID);
foreach (DataRow row in getTimeDifference)
{
TimeSpan startTime = new TimeSpan(); //Need to put the data into the bracket instead of using hard code
TimeSpan endTime = new TimeSpan(20, 00, 00); //Hard coded
TimeSpan timeDifference = new TimeSpan();
timeDifference = endTime.Subtract(startTime);
double minutes = timeDifference.TotalMinutes;
normalCount = minutes / 15;
最佳答案
您尝试过TimeSpan.Parse()
吗?
DataRow[] selectIDRow = RetailCamDataSet1.Tables["smBranchWorkingDayInfo"].Select("ID=" + ID);
foreach (DataRow row in getTimeDifference)
{
DateTime dateTime = DateTime.Parse(row["DateTimeColumn"].ToString());
TimeSpan timeSpan = TimeSpan.Parse(dateTime.ToString("hh:mm:ss"));
... //do whatever you want to do with timeSpan
}
关于c# - 从表中提取时间数据并将其放入TimeSpan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9882156/