get the first date of a month


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



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

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.