How to i get the last day of the previous month?

EricLynnWright
EricLynnWright used Ask the Experts™
on
How to i get the last day of the previous month?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

or

SELECT cast(DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) as date)

Author

Commented:
Thanks!
declare @eom datetime

set @eom = DATEADD(day, (0- (datepart(dd,GETDATE())+1)),getdate())
select @eom

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial