博客
关于我
Postgres 返回当前时间前后指定天数的集合
阅读量:795 次
发布时间:2023-03-03

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

一、需求

获取近七天的每天日期。

二、知识点整理

2.1 generate_series函数

PostgreSQL中有一个非常实用的内置函数generate_series,可以根据不同的规则生成一系列数据。这对于需要快速生成连续或间隔日期的场景特别有用。

函数 参数类型 返回类型 描述
generate_series(start, stop) int 或 bigint setof int 或 setof bigint(与参数类型相同) 生成一个数值序列,从start到stop,步进为一。
generate_series(start, stop, step) int 或 bigint setof int 或 setof bigint(与参数类型相同) 生成一个数值序列,从start到stop,步进为step。
generate_series(start, stop, step_interval) timestamp 或 timestamp with time zone setof timestamp 生成一个时间序列,从start到stop,步进为step_interval。

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

你可能感兴趣的文章
PID控制器数字化
查看>>
PIESDKDoNet二次开发配置注意事项
查看>>
PIGS POJ 1149 网络流
查看>>
PIL Image对图像进行点乘,加上常数(等像素操作)
查看>>
PIL.Image、cv2的img、bytes相互转换
查看>>
PIL.Image进行图像融合显示(Image.blend)
查看>>
Pillow lacks the JPEG 2000 plugin
查看>>
ping 全网段CMD命令
查看>>
ping 命令的七种用法,看完瞬间成大神
查看>>
Pinia:$patch的使用场景
查看>>
Pinia:$subscribe()的使用场景
查看>>
Pinpoint对Kubernetes关键业务模块进行全链路监控
查看>>
Pinterest 大规模缓存集群的架构剖析
查看>>
pintos project (2) Project 1 Thread -Mission 1 Code
查看>>
PinYin4j库的使用
查看>>
PIP
查看>>
pip install goose-extractor // SyntaxError: Missing parentheses in call to 'print'
查看>>
pip install mysqlclient报错
查看>>
pip install 出现报asciii码错误的解决
查看>>
pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding‘ 在尝试安装新软件包时
查看>>