Thursday, October 30, 2014

Returning results based on Month entry

I need to write a script that will allow the user to enter a month value, for example 'October' and it should return two values.


The 1st Monday of the month, which i think i have worked out, please see below script (please correct me if im wrong)



SELECT DATEADD(WEEK, DATEDIFF(WEEK, 0, DATEADD(DAY, 6 - DATEPART(DAY, GETDATE()), GETDATE())), 0)



and the last sunday of the same month, but because i need full weeks results meaning from Monday to Sunday, i want it to return Sunday 2nd November.


Is this possible?


No comments:

Post a Comment