博客
关于我
工作中postgre使用过的函数。
阅读量:752 次
发布时间:2019-03-23

本文共 412 字,大约阅读时间需要 1 分钟。

PostgreSQL 常用函数演示

一、字符串转时间函数

在数据处理过程中,经常需要将文本格式的时间字符串转换为可操作的时间数值。PostgreSQL 提供了 to_number(text,text) 函数这一强大工具,能够将字符串形式的日期转换为数值格式,极大地方便了数据处理和运算。

其使用方法为:

SELECT to_number('2023-10-05 14:30:00', '99999999')

参数说明:

1. 第一个参数 为日期时间字符串,例如 '2023-10-05 14:30:00';

2. 第二个参数 为格式定义字符串,这里为 '99999999',表示支持时间精度到秒级别。

注意事项:

请务必在字符串参数中包含引号,例如 '2023-10-05 14:30:00' 和 '99999999' 都需加上单引号。

以上方法可以方便地将文本时间字符串转换为便于计算的时间数值格式,从而提升数据处理效率。

转载地址:http://cvwzk.baihongyu.com/

你可能感兴趣的文章
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>
org.tinygroup.serviceprocessor-服务处理器
查看>>
org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
查看>>
org/hibernate/validator/internal/engine
查看>>
SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
查看>>
ORM sqlachemy学习
查看>>
Ormlite数据库
查看>>
orm总结
查看>>
os.path.join、dirname、splitext、split、makedirs、getcwd、listdir、sep等的用法
查看>>
os.system 在 Python 中不起作用
查看>>
OSCACHE介绍
查看>>
SQL--合计函数(Aggregate functions):avg,count,first,last,max,min,sum
查看>>
OSChina 周五乱弹 ——吹牛扯淡的耽误你们学习进步了
查看>>
OSChina 周四乱弹 ——程序员为啥要买苹果手机啊?
查看>>
OSChina 技术周刊第十期,每周技术抢先看!
查看>>
OSError: no library called “cairo-2“ was foundno library called “cairo“ was foundno library called
查看>>