Return to Snippet

Revision: 37367
at December 8, 2010 23:48 by samwa


Initial Code
CREATE  FUNCTION [GetLastDateofMonth] 
(@Date as DateTime)  

RETURNS DateTime AS  
BEGIN 

Declare @LastDate DateTime 
Set @LastDate = DateAdd(Month, 1, @Date - Day(@Date) + 1) -1

RETURN @LastDate

END
GO

Initial URL
http://www.databasejournal.com/scripts/article.php/3583671/Get-FirstLast-Date-of-Month.htm

Initial Description


Initial Title
Get last date of a month

Initial Tags
sql

Initial Language
SQL