Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting last day of the current month 1

Status
Not open for further replies.

davman2002

Programmer
Nov 4, 2002
75
0
0
US
Hi all I am really new to SQL, I normally use VB and C++. I need to know how to find out the starting date of the current month and the ending date of the current month. I noticed that there is a DATEADD function however I did not find any usefull information regarding how to use it. Any help is apreciated.

Thanks
 
This should give you the Beginning of the current month

SELECT GETDATE() - DATEPART(d, GETDATE()) + 1

This should give you the ending date of the current month.

SELECT DATEADD(m, 1, GETDATE()) - DATEPART(d, DATEADD(m, 1, GETDATE()))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top