我要取得现在时间的年,月,日,之后又要写sql语句跟一个时间字段的年,月,日,进行相等比较,
用asp是这样写的,
   YY1=year(now)
   YY2=month(now)
   YY3=day(now)
findword="year(regtime)="& YY1 &" and month(regtime)="& YY2 &" and day(regtime)="& YY3
SQL="select * from tablelog where "& findword &" order by id desc"
要实现同样的功能,用jsp如何做?请熟悉jsp的朋友帮帮忙?

解决方案 »

  1.   

    哎,csdn像滔滔江水,我放一只纸船下去,一眨眼就到了下游,我不得不用纤夫的爱把它拉回来.
      

  2.   

    java.util.Date now = new java.util.Date();
       int YY1=now.getYear();
       int YY2=now.getMonth();
       int YY3=now.getDay();
    String findword="year(regtime)="+ YY1 +" and month(regtime)="+ YY2 +" and day(regtime)="+ YY3;
    String SQL="select * from tablelog where "& findword &" order by id desc";
      

  3.   

    高兴ing!
    感谢 回复人: doway(john) ( ) 信誉:100 
    我试试,成功就结账.
      

  4.   

    String SQL="select * from tablelog where "+ findword +" order by id desc";字符串连接用 + 号。
      

  5.   

    int YY1=now.getYear();
       int YY2=now.getMonth();
       int YY3=now.getDay();
     还不行啊,上面输出的结果是
    106
    0
    6
    得不到年,月,日,为什么?
      

  6.   

    Calendar c=Calendar.getInstance();
    年c.get(1)
    月c.get(2)+1
    日c.get(6)
      

  7.   

    DateTime dt = DateTime.Now;
      

  8.   

    问题已经解决,结贴,感谢回复人: yxhzj(余华[学习J2EE中]) ( ) 信誉:100 
    感谢所有热心回复的.
    Calendar c=Calendar.getInstance();
    int  YY1  =  c.get(1);
    int  YY2  =  c.get(2)+1;
    int  YY3  =  c.get(6);String findword="year(regtime)="+ YY1 +" and month(regtime)="+ YY2 +" and day(regtime)="+ YY3;
    String strSql="select * from tablelog where "+ findword +" order by Id desc";