strTime = dsexcel.Tables[0].Rows[i]["TIME"].ToString(); //strTime = "1899-12-30 10:45:00"
(dsexcel.Tables[0].Rows[i]["TIME"].ToString().Split(' '))[1].Contains(":")/*当strTime = "10:45:00"时,这条语句越界了,故我需要判断strTime 是否有空格*/
不知如何写,请赐教!
(dsexcel.Tables[0].Rows[i]["TIME"].ToString().Split(' '))[1].Contains(":")/*当strTime = "10:45:00"时,这条语句越界了,故我需要判断strTime 是否有空格*/
不知如何写,请赐教!
解决方案 »
- 这个程序咋样 有什么问题没 自己写的
- 查看系统日志怎么写?
- 关于c#调用c++的dll的回调函数的问题,求高手帮忙,分数只有20了。
- 关于remoting的对象
- 请求帮助:C#如何用句柄建立消息连接?
- 怎样实现这样的功能!!!
- JMAIL收邮件问题,已经可以收邮件了,但是在收完一次且delete之后,再去收,为什么收到的还是第一次收的呢(注:在delete之后,我也disco
- C# combox 控件 中的这个功能 如何实现
- 需要抓取一些数据,求找到一个网页html内容被藏在哪的问题
- 如何使DataGrid(WinForm)像Excel表格那样方便好用??
- 新手基础问题贴:如何实现关闭A窗,打开MDI窗,关闭MDI窗即关闭程序
- 窗口透明 设置的问题! 新人求教!!~大侠们快来啊![续](总200分求教)
为什么不把它Convert.ToDateTime后直接操作日期???
{}
string strTime;
strTime = dsexcel.Tables[0].Rows[i]["TIME"].ToString(); //strTime = "1899-12-30 10:45:00" if ((dsexcel.Tables[0].Rows[i]["TIME"].ToString().Split(' '))[1].Contains(":")) // strTime "03:00:00" string
{
strTime = (dsexcel.Tables[0].Rows[i]["TIME"].ToString().Split(' '))[1]; //strTime = "10:30:00"
}
else
{
string tempstrtime = dsexcel.Tables[0].Rows[i]["TIME"].ToString(); //tempstrtime = "10:30:00 上午"
strTime = (tempstrtime.Substring(0, tempstrtime.IndexOf(' ') + 1)); //strTime = "10:30:00 "
} string strDate = (dsexcel.Tables[0].Rows[i]["DATE"].ToString().Split(' '))[0]; //strDate = "2008-6-28"
strTempJobTitle = dsexcel.Tables[0].Rows[i]["PROGRAM"].ToString(); //strTempJobTitle = "LATE SHOW"
if (strTempJobTitle == "")
{
continue;
} strTempChannel = tempchannel.ToString(); //strTempChannel = "2" DateTime myDateTime = DateTime.Parse(strDate + " " + strTime, new CultureInfo("en-US", true), DateTimeStyles.NoCurrentDateDefault); //myDateTime = {2008-6-28 10:30:00}
strTempDate = String.Format("{0:yyyy}-{0:MM}-{0:dd}", myDateTime) + " " + String.Format("{0:HH}:{0:mm}:{0:ss}", myDateTime); //strTempDate = "2008-06-28 10:30:00"
// 不包含 空格
else
//包含 空格
strTime = (DateTime.Parse(dsexcel.Tables[0].Rows[i]["TIME"])).ToString("hh:mm:ss");//之后出现以下报错!
Error 3 The best overloaded method match for 'System.DateTime.Parse(string)' has some invalid arguments F:\work_file\ExcelToXmlConverter\ExcelToXmlConverter\JobExporter.cs 1082 28 MC2JobExporter
Error 4 Argument '1': cannot convert from 'object' to 'string' F:\work_file\ExcelToXmlConverter\ExcelToXmlConverter\JobExporter.cs 1082 43 MC2JobExporter
Error 3 The best overloaded method match for 'System.DateTime.Parse(string)' has some invalid arguments
Error 4 Argument '1': cannot convert from 'object' to 'string'
多谢楼上的兄弟们!