zoukankan      html  css  js  c++  java
  • sql 查询三天内有效的数据

    发生发射点发

    StringBuffer sb = new StringBuffer();
    sb.append("select dmp.* from drug_presc_master where 1=1");
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    Calendar now = Calendar.getInstance();
    now.setTime(new Date());
    now.add(Calendar.DATE, 1);
    now.set(Calendar.HOUR_OF_DAY, 0);
    now.set(Calendar.MINUTE, 0);
    now.set(Calendar.SECOND, 0);
    Calendar beginDate = Calendar.getInstance();
    beginDate.setTime(new Date());
    beginDate.add(Calendar.DATE, -displayTime + 1);
    beginDate.set(Calendar.HOUR_OF_DAY, 0);
    beginDate.set(Calendar.MINUTE, 0);
    beginDate.set(Calendar.SECOND, 0);
    sb.append(" and dpm.PRESC_DATE >= TO_DATE('").append(format.format(beginDate.getTime())).append("', 'yyyyMMddHH24MIss')");
    sb.append(" and dpm.PRESC_DATE < TO_DATE('").append(format.format(now.getTime())).append("', 'yyyyMMddHH24MIss')");

    下面日期执行结果

    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    Calendar now = Calendar.getInstance();
    now.setTime(new Date());
    now.add(Calendar.DATE, 1);
    now.set(Calendar.HOUR_OF_DAY, 0);
    now.set(Calendar.MINUTE, 0);
    now.set(Calendar.SECOND, 0);
    Calendar beginDate = Calendar.getInstance();
    beginDate.setTime(new Date());
    beginDate.add(Calendar.DATE, -displayTime + 1);
    beginDate.set(Calendar.HOUR_OF_DAY, 0);
    beginDate.set(Calendar.MINUTE, 0);
    beginDate.set(Calendar.SECOND, 0);
    System.outp.println(now.getTime());
    System.outp.println(beginDate.getTime());
    System.outp.println(format.format(now.getTime()));
    System.outp.println(format.format(beginDate.getTime()));
    ------------------------------------------
    执行结果
    now.getTime():Sun Oct 15 00:00:00 CST 2017
    beginDate.getTime():Thu Oct 12 00:00:00 CST 2017
    format.format(format.format(now.getTime())):20171012000000
    format.format(beginDate.getTime()):20171015000000

    sb.append(" and dpm.PRESC_DATE >= TO_DATE('").append(format.format(beginDate.getTime())).append("', 'yyyyMMddHH24MIss')")

    dpm.PRESC_DATE:在数据库中的存储形式是 2017/8/7 19:11:27

  • 相关阅读:
    什么是一阶矩和二阶矩?
    [Pytorch]基于混和精度的模型加速
    Pytorch: 命名实体识别: BertForTokenClassification/pytorch-crf
    ipykernel_launcher.py: error: unrecognized arguments: -f /Users/apple/Library/Jupyter/runtime/kernel
    pytorch中查看gpu信息
    NLP突破性成果 BERT 模型详细解读 bert参数微调
    os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    禁用gpu首选
    Tensorflow中tf.ConfigProto()详解
    python命令之m参数 局域网传输
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7667316.html
Copyright © 2011-2022 走看看