Posted By

samwa on 12/08/10


Tagged

sql


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

samwa


Get last 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 [GetLastDateofMonth]
  2. (@Date AS DateTime)
  3.  
  4. RETURNS DateTime AS
  5. BEGIN
  6.  
  7. Declare @LastDate DateTime
  8. SET @LastDate = DateAdd(Month, 1, @Date - Day(@Date) + 1) -1
  9.  
  10. RETURN @LastDate
  11.  
  12. END
  13. GO

Report this snippet  

You need to login to post a comment.