C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Finding the first day and last day of the month using SQL


Posted Date: 05 Jun 2007    Resource Type: Code Snippets    Category: SQL Schema

Posted By: Ramamuni Reddy Mulapaku       Member Level: Silver
Rating:     Points: 10



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;





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: To find the number of columns in a table in sql server
Previous Resource: How to find which version of SQL Server 2005 is running?
Return to Discussion Resource Index
Post New Resource
Category: SQL Schema


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use