Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find last sunday

How will you find last sunday of a month in sql 2000?

like image 873
Adu Avatar asked Nov 25 '09 04:11

Adu


People also ask

How do you find last Sunday of the month in Excel?

So, life is simple, you could use =A2-WEEKDAY(A2,11) to roll the Monday back to Sunday. This logic works throughout the week, all the way up through Saturday. The WEEKDAY(,11) of a Saturday is 6, so =A2-WEEKDAY(A2,11) will subtract 6 from the date and you end up on the prior Sunday.

How do I get Sundays in Excel?

The Excel WEEKDAY function takes a date and returns a number between 1-7 representing the day of week. By default, WEEKDAY returns 1 for Sunday and 7 for Saturday, but this is configurable. You can use the WEEKDAY function inside other formulas to check the day of week.

How do I get the last Monday date in Excel?

It does this my using EOMONTH to get the last day of the month, then adding one day: = EOMONTH ( B5 , 0 ) + 1 Next, the formula calculates the number of days... The DAY function returns the day value for a date.


1 Answers

SELECT
 DATEADD(day,DATEDIFF(day,'19000107',DATEADD(month,DATEDIFF(MONTH,0,GETDATE() /*YourValuehere*/),30))/7*7,'19000107')

Edit: A correct, final, working answer from my colleague.

like image 142
gbn Avatar answered Nov 08 '22 11:11

gbn