问题标签 [sql-timestamp]

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 投票
0 回答
334 浏览

sql - 黑斑羚推拉窗

我想在 impala 中运行一个滑动窗口函数,根据 5 分钟间隔找到最高价格

换句话说,我想将我当前行的价格与过去 5 分钟内的所有行进行比较并写出最高价格

分析函数通常以行号为界,它们也可以以日期为界吗?

预期输出:

0 投票
2 回答
2948 浏览

postgresql - 如何使用 JOOQ 将 Postgres“infinity”插入时间戳字段?

我有一个这样定义的列:

使用 Postgres,我可以发出如下 SQL:

我一直在挖掘 JOOQ doco,但找不到任何处理此问题的示例。我可以用 JOOQ 做到这一点吗?它会是什么样子?

此外,是否可以使用UpdatableRecord? Timestamp我可以使用某种无限“标志”实例吗?

0 投票
1 回答
2044 浏览

java - H2 数据库 - Java 的 OffsetDateTime 和 h2 类型之间的映射

我正在使用H2 数据库进行单元测试。

OffsetDateTime根据官方 H2 文档,Java和 h2 数据类型之间没有映射(TIMESTAMP WITH TIME ZONE映射到 java 的 H2TimestampWithTimezone类型,这不是我需要的)。

有什么办法可以做到这一点?

0 投票
3 回答
189 浏览

postgresql - PostgreSQL 9.6 selects a wrong plan during aggregation against timestamp columns

I have a simple but pretty big table “log” that has three columns: user_id, day, hours.

#xA;

All columns have indexes.

The issue is that aggregation against the 'day' field works extremely slow. For example the simple query takes an eternity to complete.

#xA;

Analysis shows that Postgres makes a full scan filtering the entries that doesn’t relate to user_id = 'ab056f5a-390b-41d7-ba56-897c14b679bf' what is absolutely counter-intuitive

#xA;

And what is more strange the almost similar query works perfectly.

#xA;

Postgres selects entries for user_id = 'ab056f5a-390b-41d7-ba56-897c14b679bf' first and then aggregates among them what is obviously correct.

#xA;

There are two possible work arounds:

1) rewrite query into:

#xA;

2) Introduce pair indexes like it was suggested in finding MAX(db_timestamp) query

They could look good but I consider both ways exactly as work arounds (first one is even a hack). Logically if Postgres can select a proper plan for ‘hours’ it have to do it for ‘day’ but it doesn’t. So it looks like a Postgres bug that is occurred during aggregate of timestamp fields, however I admit that I can miss something. Could somebody please advise if something can be done here without using WAs or it’s really a Postgres bug and I have to report it?

UPD: I've reported this as a bug to the PostgreSQL bugs mailing list. I'll let everybody know if it's accepted.

0 投票
1 回答
811 浏览

java - 在 TIMESTAMP 中保存 LocalDateTime 时出错

我正在使用Java 8Hibernate 5.2.9 我有一个包含变量 end 的对象

在数据库中,该字段定义为

所以当我尝试做

我明白了

不确定我到底在做什么错,因为我假设 java 8 和 hibernate 5.2.9 知道是什么LocalDateTime。我会很感激任何帮助,因为我被困住了。

0 投票
2 回答
1359 浏览

sql - SQL 命令中的 TIMESTAMP 和 CURRENT_TIMESTAMP 问题

我在创建CURRENT_TIMESTAMP用于指定日期的表时遇到了一些问题。我需要这个,因为我使用 java jpa 实体按日期检索它们。如果我运行到本地 h2 数据库,我没有问题。

在这个例子中:

一切都被创建并完美运行,但是当我在我连接的 Azure SQL 数据库中尝试相同的查询时,我得到了错误

无法执行查询。错误:无法将显式值插入时间戳列。将 INSERT 与列列表一起使用以排除时间戳列,或将 DEFAULT 插入时间戳列。

如果我尝试改变CURRENT_TIMESTAMPTIMESTAMP我会得到;

无法执行查询。错误:列名“TIMESTAMP”无效。如果我将其更改为 DEFAULT,因为先前的错误表明已创建表,但我无法按创建日期检索它们,因为 DEFAULT 不是时间值。

完整查询

0 投票
1 回答
81 浏览

sql - 获取每个 TIMESTAMP 的最新记录

我有这个查询:

结果:

我需要每个 TIMESTAMP 的最新记录,我应该得到这个:

我如何得到它?

如您所见,TIMESTAMP 和 TIMESTAMP_OFFER 可以有重复的值,但 TIMESTAMP_TRACK 是唯一的。

0 投票
3 回答
1130 浏览

mysql - 对查询中产生的多次求和 (timediff)

我有两个领域:

  • 初始(时间戳)
  • 最终(时间戳)

我的查询是:

结果将类似于

是否有可能进一步总结这些多个时间戳,以便获得总工作时间?

示例数据集(以 csv 格式导出):

期望的输出(它是工作时间的总和):

提前致谢

0 投票
1 回答
117 浏览

mysql - MySQL DATE_ADD 不选择数据

我需要选择开始 = 当前日期 + 3 天的行。

假设当前日期是 2017 年 9 月 23 日。

我的查询是:

查询正在运行,但没有给出任何结果。我绝对确定有一行对应选择参数。我的查询有什么问题?

0 投票
1 回答
5086 浏览

mysql - MySQL 不正确的时间戳值

我正在尝试在时间戳列中插入日期时间值“1970-01-01 00:00:01”,但 MySQL 返回错误“日期时间值不正确:“时间戳”列的“1970-01-01 00:00:01” "

我很困惑,因为 MySQL 文档声称时间戳的最低有效值为 '1970-01-01 00:00:01'。出了什么问题,什么是真正的最低时间戳值?谢谢。