如何更新DateTime()中的时间以定期时间间隔以递增顺序访问?
对于特定的记录集,我想以4分钟的差异更新时间。比如时间
03-06-2015 11:45:37 AM.
现在我要更新20条记录,时差为4分钟,即
03-06-2015 11:45:37 AM,
03-06-2015 11:49:37 AM,
03-06-2015 11:53:37 AM,
03-06-2015 11:57:37 AM,
03-06-2015 12:01:37 PM,
03-06-2015 12:05:37 PM
答案 0 :(得分:0)
打开一个包含20条记录的记录集,并从第一条记录中读取时间(StartTime)。
然后遍历记录集,为您设置的每条记录执行编辑和更新:
rs.Edit
StartTime = DateAdd("n", 4, StartTime)
rs!YourTimeField.Value = StartTime
rs.Update
rs.MoveNext
查询可能如下所示:
SELECT DISTINCT
10 * Abs([Deca].[id] Mod 10) + Abs([Uno].[id] Mod 10) AS Id,
DateAdd("n",[Id] * 4, [StartTime]) AS NextTime
FROM
msysobjects AS Uno,
msysobjects AS Deca
WHERE
(10*Abs([Deca].[id] Mod 10) + Abs([Uno].[id] Mod 10)) < 20;
结果:
Id NextTime
0 03-06-2015 11:45:37
1 03-06-2015 11:49:37
2 03-06-2015 11:53:37
3 03-06-2015 11:57:37
4 03-06-2015 12:01:37
5 03-06-2015 12:05:37
6 03-06-2015 12:09:37
7 03-06-2015 12:13:37
8 03-06-2015 12:17:37
9 03-06-2015 12:21:37
10 03-06-2015 12:25:37
11 03-06-2015 12:29:37
12 03-06-2015 12:33:37
13 03-06-2015 12:37:37
14 03-06-2015 12:41:37
15 03-06-2015 12:45:37
16 03-06-2015 12:49:37
17 03-06-2015 12:53:37
18 03-06-2015 12:57:37
19 03-06-2015 13:01:37