当前位置:网站首页>postgresql 按日期范围查询
postgresql 按日期范围查询
2022-06-21 10:46:00 【Yield & Allure】
实体类
package com.yunhe.jvmjiazai;
import java.util.Date;
/**
* @author by houbing
* @date 2022/6/20 20:22
* @Classname Order
* @Description TODO
*/
public class Order {
private String name;
private Date createTime;//订单的创建时间,保存到数据库中,在数据库中类型为timestamp
private String beginTime;//前端传到后端的开始时间,不需要保存数据库中
private String endTime;//前端传到后端的结束时间,不需要保存数据库中
public Order() {
}
public Order(String name, Date createTime, String beginTime, String endTime) {
this.name = name;
this.createTime = createTime;
this.beginTime = beginTime;
this.endTime = endTime;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
@Override
public String toString() {
return "Order{" +
"name='" + name + '\'' +
", createTime=" + createTime +
", beginTime='" + beginTime + '\'' +
", endTime='" + endTime + '\'' +
'}';
}
}
这里我用的数据库语言是 postgresql ,在日期上处理不同于MySQL数据库
查询在开始时间到结束时间中所有创建的订单信息(开始时间与结束时间均是前端传来的)
<select id="findLike" resultType="com.yunhe.entity.Order">
select *
from order
<where>
<if test="beginTime!=null and beginTime!=''">
and createTime >= to_date(#{beginTime},'yyyy-mm-dd')
<--and createTime >= to_date(#{beginTime}, 'yyyy-mm-dd')-->
</if>
<if test="endTime!=null and endTime!=''">
and createTime < to_date(#{endTime},'yyyy-mm-dd')
<--and createTime <= to_date(#{endTime}, 'yyyy-mm-dd')-->
</if>
</where>
</select>边栏推荐
- js正则-梳理
- 02. Redis Blockbuster: viewing core principles from high-frequency problems
- New programmers optimize a line of code on Monday and are discouraged on Wednesday?
- ES复合查询工作量评估
- Simple implementation of Snake game in C language
- Summary of mapping methods (chain mapping method using hash map)
- leetcode:715. Range 模块【无脑segmentTree】
- TS——枚举
- TS - Enumeration
- Do website from scratch 11- blog development
猜你喜欢

Ccs7.3 how to erase only part of the flash sector when burning DSP on-chip flash (two projects of on-chip flash burning of a DSP chip)

is not allowed to connect to this mysql server

Prometheus Flask exporter使用示例

Xidian AI ranked higher than Qingbei in terms of AI major, and Nantah ranked first in China in terms of Software Science in 2022

TS——枚举

WPF DataContext usage

Research and implementation of embedded software framework based on multi process architecture

Starting a prairie fire, Alibaba cloud database "hundred cities gather together" to help small and medium-sized enterprises' digital intelligence transformation

中国国际电子商务中心与易观分析联合发布:2021年4季度全国网络零售发展指数同比增长0.6%

【zz】owt-server:音视频转发示意图
随机推荐
聊聊大火的多模态项目
WPF DataContext 使用
【obs】libobs_winrt.dll
Actual measurement: the performance of cloud RDS MySQL is 1.6 times that of self built
Eig and Saudi Aramco signed a memorandum of understanding to expand energy cooperation
Quickly analyze oom using mat tools
2. MySQL index creation method and its optimization
Mythical games announced its cooperation with kakao games, a leading Korean game publisher, to promote business expansion in the Asia Pacific Region
ESP8266/ESP32 +1.3“ or 0.96“ IIC OLED指针式时钟
Xidian AI ranked higher than Qingbei in terms of AI major, and Nantah ranked first in China in terms of Software Science in 2022
Use of jobservice
Introduction to ThreadPoolExecutor
Add solid state to the computer
FastAPI Web框架 [Pydantic]
触摸按键控制器TTP229-BSF使用心得[原创cnblogs.com/helesheng]
02. Redis Blockbuster: viewing core principles from high-frequency problems
Why does C throw exceptions when accessing null fields?
中国国际电子商务中心与易观分析联合发布:2021年4季度全国网络零售发展指数同比增长0.6%
What securities does qiniu use to open an account? Is it safe to open an account
MySQL - Database Foundation