Posted By

samwa on 12/08/10


Tagged

sql


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

samwa


get the first date of a month


 / Published in: SQL
 

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

  1. CREATE FUNCTION [GetFirstDateofMonth]
  2. (@Date AS DateTime)
  3.  
  4. RETURNS DateTime AS
  5. BEGIN
  6.  
  7. Declare @FirstDate DateTime
  8. SET @FirstDate = DateAdd(Day, 1, @Date - Day(@Date) + 1) -1
  9.  
  10. RETURN @FirstDate
  11.  
  12. END
  13.  
  14. GO

Report this snippet  

You need to login to post a comment.