mysql - Last working day in DB -


i have data days of week , want find data recent working day i.e dayofweek != 1 , dayofweek != 7

my clumsy case along lines of

where case when dayofweek(curdate()) = 1 day(time) = date_sub(day(time), interval 2 day)      when dayofweek(curdate()) = 7 day(time) = date_sub(day(time), interval 1 day)       when dayofweek(curdate()) != 7 , dayofweek(curdate()) != 1 day(time) = day(curdate())  else 1 = 1  end 

this code, day(time) = date_sub(day(time), interval 2 day) never matches, because day(time) never ever equals day(time) - 1 day. same saying x=x-1 in algebra... can not true. suspect mean this:

where case when dayofweek(curdate()) = 1 date(time) = date(date_sub(curdate(), interval 2 day))  ... ... ... part left exercise asker. 

the date() function removes time part, can compare day. the date_sub() function needs subtract curdate() recent workday. in code subtracting datetime stored in table.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -