数据库中存的是类似 2001-01-1格式的数据,现在在页面接收字符串 200101 想把2001年01月份的数据都查出来 ,怎么操作 谁能给个思路
解决方案 »
- ~~~~~~请问大家,还有人用~~~~ANT~~~给JAVA工程或WEB工程打包的吗?~~~~~~
- openmeetings部署出错求解
- hibernate 写hql 一对多查询时,如何将多的数据整合在一条?
- SSH +dwr 用户登录 存放session 遇到问题了 求大家解决 谢谢
- java.sql.*包 在哪个jar中
- md5加密为何要设hexDigits值
- 关于SUPER的用法.附上实例.请大家帮忙.谢谢.
- J2EE中tier和layer的概念和区别是什么?
- 给点意见,好吗?
- SUN ONE STUDIO 中EJBQL的问题.郁闷.
- 修改信息时输入非法数据如何跳回修改页面并给出错误提示
- 未找到预期 FROM 关键字
select * from YourTable
where a_date>=to_date('2010-01-01', 'yyyy-MM-dd')
and a_date<to_date('2010-02-01', 'yyyy-MM-dd')
Date dd = new SimpleDateFormat("yyyy-MM-dd").format("200101");
然后写查询语句
String month = map.get("month").toString();
//时间转化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
java.sql.Date startDate = null;
try {
if (!"".equals(month)) {
startDate = new java.sql.Date(sdf.parse(month).getTime());
}
} catch (ParseException e) {
e.printStackTrace();
log.error("日期格式转化错误");
throw new HdbException(e.getMessage(), "hedbsqlerror");
}
//不知,lz想要什么样的
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
String strStart ="201001";
String strEnd=strStart;
strStart = strStart+"01"; //月头时间20100101
Date date = sf.parse(strStart);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
strEnd = strEnd+cal.getActualMaximum(Calendar.DAY_OF_MONTH); //月尾时间20100130
if (!"".equals(month)) {
querySql += " and time = '"+startDate+"'";
}