我在MS Excel 2013中有一个数据集,如下所示:
+------+------------+----------------+
| Name | DateWorked | HoursCompleted |
+------+------------+----------------+
| abc | 03/01/2016 | 4:53 |
| abc | 03/02/2016 | 5:22 |
| ghi | 03/03/2016 | 2:10 |
| jkl | 03/04/2016 | 5:30 |
| mno | 03/05/2016 | 4:20 |
| pqr | 03/06/2016 | 0:20 |
+------+------------+----------------+
其中Name
为字符串,DateWorked
为mm / dd / yyyy,HoursCompleted
为h:mm数据类型/格式。
我正在使用ADODB来获取这些数据的结果,将其存储在ADODB.Recordset中并显示在另一张表中。
我的代码/查询看起来像这样:
countCommand.CommandText = "SELECT SUM([HoursCompleted]) FROM [Sheet1$] WHERE [Name] = 'abc' AND [DateWorked] BETWEEN #02/28/2016# AND #03/02/2016#"
Set countResults = countCommand.Execute
现在这就像一个魅力,给我一个10:15
的结果。
但是,如果DateWorked
下的第一个值不是Date
数据类型,那么我无法获得结果。例如,如果我的数据如下所示:
+------+------------+----------------+
| Name | DateWorked | HoursCompleted |
+------+------------+----------------+
| abc | Not worked | 0:00 |
| abc | 03/02/2016 | 5:22 |
| ghi | 03/03/2016 | 2:10 |
| jkl | 03/04/2016 | 5:30 |
| mno | 03/05/2016 | 4:20 |
| pqr | 03/06/2016 | 0:20 |
+------+------------+----------------+
如何设置列的数据类型?