问题标签 [datetime-generation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
5 回答
11079 浏览

mysql - MySQL GROUP BY DateTime +/- 3 seconds

Suppose I have a table with 3 columns:

  • id (PK, int)
  • timestamp (datetime)
  • title (text)

I have the following records:

I need to do a GROUP BY records that are within 3 seconds of each other. For this table, rows 1 and 2 would be grouped together.

There is a similar question here: Mysql DateTime group by 15 mins

I also found this: http://www.artfulsoftware.com/infotree/queries.php#106

I don't know how to convert these methods into something that will work for seconds. The trouble with the method on the SO question is that it seems to me that it would only work for records falling within a bin of time that starts at a known point. For instance, if I were to get FLOOR() to work with seconds, at an interval of 5 seconds, a time of 15:00:04 would be grouped with 15:00:01, but not grouped with 15:00:06.

Does this make sense? Please let me know if further clarification is needed.

EDIT: For the set of numbers, {1, 2, 3, 4, 5, 6, 7, 50, 51, 60}, it seems it might be best to group them {1, 2, 3, 4, 5, 6, 7}, {50, 51}, {60}, so that each grouping row depends on if the row is within 3 seconds of the previous. I know this changes things a bit, I'm sorry for being wishywashy on this.

I am trying to fuzzy-match logs from different servers. Server #1 may log an item, "Item #1", and Server #2 will log that same item, "Item #1", within a few seconds of server #1. I need to do some aggregate functions on both log lines. Unfortunately, I only have title to go on, due to the nature of the server software.

0 投票
2 回答
637 浏览

c# - 需要根据年-周-日计算日期

当我收到年份、星期数和星期几时,如何计算 C# 中的日期。例如:年 = 2011 周 = 27 天 = 6

结果应该是 2011-7-10


谢谢大家。我根据维基百科算法解决了它。

0 投票
1 回答
480 浏览

mysql - MySql 查询:包括具有 COUNT(id) == 0 但仅在过去 30 天内的天

我正在查询从我们的数据库中获取过去 30 天每天的构建次数。但是也需要标记没有构建的日子。

在我的 WHERE 子句中,我使用 submittime 来确定是否有构建,我如何修改它以包含 COUNT(id) == 0 但仅在过去 30 天内的天数。

原始查询:

我试过的:

0 投票
1 回答
269 浏览

android - 时间和日期显示

如何在没有 java 或 Picker 的情况下显示日期和时间,就像这样简单TimeView

我会从设备上获取时间或日期。时间/日期选择器占据了很大的展示空间。

0 投票
2 回答
156 浏览

android - 获取过去三年之间的数据,

我正在尝试在过去三年之间加载数据。我想获取当前日期时间和过去 3 年前之间的数据。

例如:-从 2009 年 1 月 19 日到当前时间(2012 年 1 月 19 日)

我得到的当前时间如下。

有人可以告诉我这样做的方法吗?如果您有任何示例,那将是一个真正的帮助!

0 投票
1 回答
117 浏览

mysql - 获取字段总和

可能重复:
过去 7 天的 MySQL 计数数据

我有一个问题,我需要显示字段的总和。假设我有一个记录集如下,

我想显示一个输出,它将显示每天所有感染的总和,如下所示,

我使用了这个查询,

但它只给出如下输出,这不是我的要求..

任何帮助都会很有帮助:)非常感谢:)非常感谢:)

编辑: 可能重复:MySQL Count data for last 7 days

但不相似