- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要在 PostgreSQL 数据库中以 yyyy-mm-dd hh:mm:ss.SSS
(SSS 代表毫秒)格式存储时间戳。当然它可以用作文本/或 varchar,但我需要使用时间戳“工作”(例如,过滤某个时间戳之前的所有实例 - 考虑毫秒)。我将如何在 PostgreSQL 中执行此操作?
最佳答案
我知道这是一个老问题,但我遇到了类似的问题。
您可以使用 timestamp(n) 字段,其中 n 等于存储日期的精度位数(timestamp(3) 将为您提供毫秒精度)
示例
CREATE TABLE date_test (datetime timestamp(3) with time zone);
insert into date_test values(to_timestamp(1525745241.879));
select EXTRACT(epoch FROM datetime) from date_test;
注意:在当前版本的 postgres 中,时间戳存储为整数,因此不会引起浮点舍入问题
关于database - 如何在 PostgreSQL 中以毫秒为单位存储时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37139033/
给定一个带有多个 date_time 戳的字符串,我想 提取第一个戳及其前面的文本 候选字符串可以有一个或多个时间戳 后续的 date_time 戳记将被 sep="-" 隔开 后续date_time
是否可以合并从相机拍摄的文本和照片?我想在照片上标记日期和时间,但我在 Google 上找不到任何内容。 最佳答案 使用下面的代码来实现你所需要的。 Bitmap src = Bitm
有没有办法通过 Graph API 戳另一个用户?基于this post ,并使用 Graph Explorer ,我发布到“/USERID/pokes”,我已经授予它(Graph API 应用程序和
我有两个向左浮动的元素。一个是 body 的第一个 child ,另一个是容器的第一个 child ,容器是 body 的第二个 child 。 ...
我是一名优秀的程序员,十分优秀!