I hv a database "signdetail" which is let users sign in and sign out.

signdetail:
userid | login | logout


String sqlsign = "SELECT MAX(login) AS login1, DATEDIFF(day, MAX(login), getdate()) AS absentday FROM signdetail WHERE userid=?";

sql above will return the result TOTAL DAYS NOT SIGN IN btw their last sign in date and current day.

But I have to minus this absentday with how many sunday btw their last sign in date and current day.

Much appreciate if anyone can give me some idea..
Is it something like

String sqlsun = "SELECT COUNT(*) FROM (SELECT TO_DATE(MAX(login), getdate()) dt FROM signdetail) WHERE TO_CHAR(dt,'Day') = 'Sunday';"
??