求两个时间段间的工作日(周一到周五)

create function countworkday(first date, last date ) returns int
begin
declare datetemp date;
set @totalday = 0;
set datetemp = first;
while datetemp <= last do
if DAYOFWEEK(datetemp) <7 && DAYOFWEEK(datetemp) >1 then
set @totalday = @totalday + 1;
end if;
set datetemp = date_add(datetemp, INTERVAL 1 DAY);
end while;
return @totalday;
end

你可能感兴趣的:(Mysql,工作,Java)