我要取得现在时间的年,月,日,之后又要写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的朋友帮帮忙?
用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的朋友帮帮忙?
解决方案 »
- 使用swfupload基于ssh上传文件出错误
- jsp数据库连接时出现java.lang.NullPointerException错误
- DWR3.0 反ajax讨论
- 求助!!jsp网站上传后访问数据库很慢
- S.S.H框架,如果系统越做越大,配置文件也越来越大,这个文件的内容大小有限制吗?
- 郁闷 2000下正常的JDBC连接页面 换到XP+SP2怎么不行
- 【jsp求助】java.lang.NumberFormatException: null【跪谢】
- 装了JBuilder,但是所有和Servlet相关的类都找不到
- shtm是什么技术,jsp又是什么技术?
- myeclipse 导入web项目出错怎么改?求大神
- hibernate中主键生成问题
- TOMCAT 与 resin 的request用法是不是不一样呢,出现乱码,在线等待
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";
感谢 回复人: doway(john) ( ) 信誉:100
我试试,成功就结账.
int YY2=now.getMonth();
int YY3=now.getDay();
还不行啊,上面输出的结果是
106
0
6
得不到年,月,日,为什么?
年c.get(1)
月c.get(2)+1
日c.get(6)
感谢所有热心回复的.
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";