What I want to do is so you have a list of random dates, it will never be the same so it has to be a universal formula, but you get any date, any date of the year and then e
For new Java 8 Time API, you can use below code. You need to change DayOfWeek.THURSDAY
etc in the below code.
LocalDate date1=LocalDate.now();
// This will give you int value of Day(for eg. Friday) and the date you want to check for
int duration=DayOfWeek.WEDNESDAY.getValue()-date1.getDayOfWeek().getValue();
System.out.println("duration "+duration);
if(date1.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)) {
System.out.println("Wednesday");
} else {
date1=date1.plusDays(7).minusDays(7- duration);
}
// it will first give next day of week then minus the duration from 7.
System.out.println("new date1 "+date1);
This formula will give you the Thursday following a date in A1
=A1+7-WEEKDAY(A1+2)
If A1 is a Thursday it returns that date, if it should be A1+7 if A1 is Thursday then change to this version
=A1+8-WEEKDAY(A1+3)
=IF(WEEKDAY(A1) < 5, A1+5-WEEKDAY(A1), A1+5+7-WEEKDAY(A1))
Will give you the next Thursday from the date given in Cell A1 in Excel. If the input date is a Thursday, it will give the next Thursday.
Use <= in the conditional if you want to display the input Thursday when given a Thursday, rather than displaying the next Thursday.