Get last date of a month


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.