假设表结构:用户名,日期,上班时间,下班时间.8月份记录:select * from 表名 where month(日期)=8 and 用户名 = '小张'8月份迟到早退次数:select sum(iif(datediff('s','8:00',上班时间) > 0,1,0)) as 迟到次数,sum(iif(datediff('s','17:00',下班时间) < 0,1,0)) as 早退次数 from 表名 where month(日期) = 8 and 用户名 = '小张' select
#今天 select * from or_order_task where to_days(created_date)=to_days(now()); #近七天 select * day )<=date(created_date); #近七天 select * day )<=date(created_date); #本月 select * from or_order_task where date_format(created_date, '%Y%m') = date_format(curda
---注意:这里统计的周末包括周5,周6,但不包括周日ALTER FUNCTION [dbo].[GetWeekDaysByMonth] ( @Year INT, @Month INT, @Day INT ) RETURNS INT AS BEGIN ); , , , ; , , , ), , , )) ); --月天数 ; BEGIN ;---周几 END; ELSE BEGIN SET @weekday = DATEPART(WEEKDAY, @date);---周几 END; BEGIN
话不多说,直接上代码 public class Test { @org.junit.Test public void tets() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); //获取前月的第一天 for (int i = 0; i >-7; i--) { Calendar cal_1 = Calendar.getInstance();//获取当前日期 cal_1.add(Calendar.MON