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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Function

Status
Not open for further replies.

bxgirl

Programmer
Nov 21, 2005
75
US
I'm interested in getting the 1st day and last day of the previous month. Is there a function that does this or will I need a combination of functions?

Thanks.
 
Code:
-- first day of prev month
select dateadd(mm, datediff(mm, 0, getdate())-1, 0)

-- last day of prev month
select dateadd(mm, datediff(mm, 0, getdate()), -1)

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top