我有一个MySQL数据库,该表存储具有DateTime数据类型列的行。
int todayuser=0;
try{
Connection con = (Connection)session.getAttribute("connection");
Statement smt = con.createStatement();
ResultSet rs= smt.executeQuery("SELECT * from user_information where signup_date = CURDATE()");
while(rs.next()){
HashMap<String, String> map = new HashMap<String, String>();
map.put("userid", rs.getString("userid"));
map.put("name", rs.getString("name"));
map.put("email", rs.getString("email"));
map.put("signup_date", rs.getString("signup_date"));
allrequestlist.add(map);
todayuser = allrequestlist.size();
}
}
catch(Exception e){
out.println(e);
}
现在,我想获取今天存储的总行数。 CURDATE()也有yyyy-mm-dd HH:MM:SS:
答案 0 :(得分:0)
使用MySQL的Now()函数。