Javascript——日期选择器(sql)查询当天时间的数据,注意⚠️时间2023-04-28 00:00:00-2023-04-28 23:59:59

*查询当天时间的数据,注意⚠️时间2023-04-28 00:00:00-2023-04-28 23:59:59

**api :日期格式
使用format指定输入框的格式;使用value-format指定绑定值的格式。
**

 <el-date-picker
	   v-model="valueTime"
	    type="daterange"
	    range-separator="-"
	    format="yyyy-MM-dd"
	    value-format="yyyy-MM-dd"
	    start-placeholder="开始时间"
	    end-placeholder="结束时间"
	  >
  </el-date-picker>
getData() {
      let sqlDict = `select * from dict where 1=1`;
      let sqlModel1;
      if (this.valueTime.length > 0 && !this.unicode_name) {
        this.starTime = this.valueTime[0] + ' 00:00:00';
        this.endTime = this.valueTime[1] + ' 23:59:59';
        sqlModel1 = `select * from cacu_center_record where 1=1 and create_time >= '${this.starTime}' and create_time <= '${this.endTime}' and model_id='${this.logId}'`;
      } else if (this.unicode_name && this.valueTime.length == 0) {
        sqlModel1 = `select * from cacu_center_record where 1=1 and crew_name='${this.unicode_name}' and model_id='${this.logId}'`;
      } else if (this.unicode_name && this.valueTime.length > 0) {
        this.starTime = this.valueTime[0] + ' 00:00:00';
        this.endTime = this.valueTime[1] + ' 23:59:59';
        sqlModel1 = `select * from cacu_center_record where 1=1 and create_time >= '${this.starTime}' and create_time <= '${this.endTime}' and crew_name='${this.unicode_name}' and model_id='${this.logId}'`;
      } else {
        sqlModel1 = `select * from cacu_center_record where 1=1 and model_id='${this.logId}'`;
      }
      req(sqlModel1).then(res => {
        this.tableData = res.rows; //表格数据
        this.tableData.sort(function(a, b) {
          return Date.parse(b.period_time) - Date.parse(a.period_time); // 时间倒序
        });
        this.total = res.rowCount;
        this.tableData = this.tableData;
      });
    },
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值