mysql where条件:某时间字段为今天的sql语句
1.查询:注册时间为今天的所有用户数:
select count(*) from customer where TO_DAYS(createtime) = TO_DAYS(NOW())
2.获取当前时间到凌晨24点还有多长时间:(Java中可用于判断某时间是否为今天)
final
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) +
1
);
cal.set(Calendar.HOUR_OF_DAY,
0
);
cal.set(Calendar.MINUTE,
0
);
cal.set(Calendar.SECOND,
0
);
cal.set(Calendar.MILLISECOND,
0
);
final
double
diff = cal.getTimeInMillis() - System.currentTimeMillis();