Return to Snippet

Revision: 37366
at December 8, 2010 23:46 by samwa


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

RETURNS DateTime AS  
BEGIN 

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

RETURN @FirstDate

END

GO

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

Initial Description

                                

Initial Title
get the first date of a month

Initial Tags
sql

Initial Language
SQL