I am storing some days and hours as timestamp in my MySQL table. What I want to do now is retrieve every day that a specific user worked from last Sunday until the Sunday before (One week of work). And the other option is retrieve every day from today until last Sunday (current week). Some employees does not work everyday.
I don’t know how I can code this in Java or whether there is a specific MySQL function.
in Java, you can put the Calendar class to good use to find the previous Sunday :
Calendar c = Calendar;c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);Date lastSunday = c.getTime();you can then decrement by 1 WEEK_OF_MONTH to find the Sunday before that :
c.add(Calendar.WEEK_OF_MONTH, -1);Date sundayBeforeThat = c.getTime();