postgresql 按创建日期范围查询

Amos 2022-07-22 11:41:47

DTCloud  postgresql 按创建日期范围查询

方法一:

select * from res_users where create_date >= '2022-01-01' and create_date < '2022-07-01';

方法二:为啥字符串可以按日期格式比较大小

select * from user_info where create_date res_users '2022-01-01' and '2022-07-01';

方法三:

select * from res_users where create_date >= '2022-01-01'::timestamp and create_date < '2022-07-01'::timestamp;

方法四:

select * from user_info where create_date res_users to_date('2022-01-01','YYYY-MM-DD') and to_date('2022-07-01','YYYY-MM-DD');

创建下载记录

self._cr.execute("INSERT INTO documents_download(document_id, user_id, create_date)VALUES (%s, %s,now())", (obj.document_id.id,int(kw[0]['uid'])))

 

...全文
192 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,920

社区成员

发帖
与我相关
我的任务
社区描述
DTCloud是一套基于Pthon+Go开源商业应用程序.主要面向建筑工程行业,物联网行业,数字化行业,打造的企业信息一体化的解决方案。
物联网 企业社区
社区管理员
  • 中亿丰数字科技集团有限公司
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧