Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复日期格式不正确导致查询不到数据 #199

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lvchaxiaoqingwa
Copy link

时间字符串参数是yyyy-MM-dd形式,数据库数据包含HH:mm:ss 匹配不上,创建betweenFormatIfPresent方法把前端传的时间参数补上00:00:00和23:59:59

@oddfar
Copy link
Owner

oddfar commented Jan 12, 2024

sql条件中如果只包含年月日,不包含 HH:mm:ss,在查询时会自动补上00:00:00,会造成查询结果是不准确的

例如 select * from (table) where (time) between ''2021-01-05" and "2021-01-06"
查询时候会被转成2021-01-05 00:00:00 以及 2021-01-06 00:00:00,这样06日当天的数据就只能查到00:00:00这一秒的数据。就算结束时间加一天改为07日,查询时结束时间转为2021-01-07 00:00:00,06当天的全天数据确实可以查询到了,但是数据库中时间为2021-01-07 00:00:00的这条数据同样会被查询出来,查询的结果就会多出07日的00:00:00这一秒的数据,数据就不准确了。

前端传入时加上时间就好,例如以下案例:

        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>

@272778299
Copy link

    <el-date-picker
      v-model="dateRange"
      style="width: 240px"
      value-format="yyyy-MM-dd HH:mm:ss"
      type="datetimerange"
      range-separator="-"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
    ></el-date-picker>

这段代码上传到前端哪个地方呀?

@oddfar
Copy link
Owner

oddfar commented Feb 4, 2024

    <el-date-picker
      v-model="dateRange"
      style="width: 240px"
      value-format="yyyy-MM-dd HH:mm:ss"
      type="datetimerange"
      range-separator="-"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
    ></el-date-picker>

这段代码上传到前端哪个地方呀?

全局搜索,替换代码

@272778299
Copy link

    <el-date-picker
      v-model="dateRange"
      style="width: 240px"
      value-format="yyyy-MM-dd HH:mm:ss"
      type="datetimerange"
      range-separator="-"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
    ></el-date-picker>

大概代码上传到前端哪个地方呀?

全局搜索,替换代码

能加下Q指导下吗。272778299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants