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日

悬赏问题

  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化