【问题标题】:Removing seconds from the time field in MS Access without updating the table从 MS Access 中的时间字段中删除秒而不更新表
【发布时间】:2016-02-08 16:49:37
【问题描述】:

美好的一天

我有一个包含用户和时间戳的表。我需要计算在任何给定时间有多少用户使用了系统。这将有助于查看高峰时段。问题是秒数正在分开我的计数。例如,我将有 4 个相同的时间戳 [11:45,11:45, 11:45] 因为不同的秒数。有没有办法在不更新表格的情况下删除它们。所有的格式化功能都不起作用!提前致谢

代码如下;

SELECT distinct mid(Format (u.time), 1,5) as Time,
(select count(u1.student_id) from uselog u1 where u1.time = u.time) as users FROM uselog u

【问题讨论】:

标签: sql ms-access timestamp


【解决方案1】:

只需四舍五入:

Select Distinct
    TimeSerial(Hour(u.time), Minute(u.time), 0) As [time],
    (Select Count("*") From uselog As u1 Where TimeSerial(Hour(u1.time), Minute(u1.time), 0) = u.time) As users 
FROM 
    uselog As u

【讨论】:

  • Select Distinct TimeSerial(Hour(u.time), Minute(u.time), 0) As "time", count (u.student_id) as users FROM uselog As u GROUP BY TimeSerial(Hour (u.time), 分(u.time), 0);带有子选择的那个导致 MS Access 冻结,但感谢您的解决方案
  • 好吧,潜艇不是我的主意。我觉得很奇怪。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-02
  • 1970-01-01
  • 2018-07-08
相关资源
最近更新 更多