qq_28573739 2016-03-11 08:29 采纳率: 100%
浏览 2326
已采纳

我要用判断sql查到的时间距离现在是否3天后。

String queryString = "SELECT c.couponname,c.couponfee/100,c.pic1_path,date_format(c.endtime,'%Y-%c-%d') as endTime FROM couponpublish c,couponpool s WHERE s.pubid=c.pubid AND s.owner='"+userId+"' ";
String whereString="";
//优惠卷类别 1.可用;2.历史
if(type==1){
whereString=whereString+" and ( '"+nowTime+"' between c.starttime and c.endtime ) and s.status=3 ";
}else{
whereString=whereString+" and (( '"+nowTime+"' > c.endtime ) or s.status>3 )";
}

        String orderString=" order by c.updatetime ";

        int offset=PagerUtil.getOffset(Integer.valueOf(page),Integer.valueOf(rows));
        List<Map> list=super.findListbySqlReturnMapByPage(queryString+whereString, offset, Integer.valueOf(rows));

        System.out.println(list);        
        attributes.put("coupons", list);

    }else{
        throw new InterfaceException(new ErrorBean(ErrorCode.USER_NO_LOGIN));
    }

    return  attributes;

怎么写判断当前时间是否是查到的时间的三天前,然后写在list里

  • 写回答

3条回答

  • 姚__ 2016-03-11 08:45
    关注

    看下sql的datediff函数,或者读取出时间,转成date类,调用getTime()方法,返回long值再比较

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 11月29日

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题