This code sample shows how to find the first day and last day of the month.
The following script prints the first day of the month. For example, the the 1st day of August 2007 is a 'Wednesday'.
select datename(weekday,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)) CurrentMonthFirstDay;
Output: Wednesday
The following script prints 'Friday, if executed in August 2007.
SELECT datename(weekday,DateAdd(day, -1, DateAdd(month, DateDiff(month, 0, getdate())+1, 0))) CurrentMonthLastDay;
|
No responses found. Be the first to respond and make money from revenue sharing program.
|