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

Determine last day of the month 1

Status
Not open for further replies.

lhrpa

Programmer
Apr 2, 2003
10
US
I would like to be able to compare a date within my data to the last day of the previous month, is there a last day function of some sort in SQL Server?

Thanks for any guidance!

Linda
 
How about this,

select dateadd(d,-day(<date_column_name>),dateadd(m,1,<date_column_name>)) as lastdayofmonth from <table_name>

Hope that this helps.

-dinzana
 
Check this thread, there are some other solutions, also.

Take care,

dinzana

thread183-459528
 
Thanks, that's perfect! I'll also check out the other thread. Thanks a lot for your help,

Linda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top