Date d = new Date(); java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-00"); java.text.SimpleDateFormat dateFormat1 = new java.text.SimpleDateFormat("yyyy-(MM+1)-00"); String s = dateFormat.format(d); String s1 = dateFormat1.format(d); String sql1="select * from wage where userid = ? and time >= ? and time < ? "; pstmt = conn.prepareStatement(sql1); pstmt.setInt(1, 1); pstmt.setString(2, s); pstmt.setString(3, s1);
想求教各位高手,我获取到当前时间后,通过格式化截取获得了年和月,怎么取得数据库表中相同月份的数据。我写了点代码,但是行不通,取不到数据,请各位高手帮我看看,简略的代码附上。 我数据表中time是 timestamp类型