Find Start of a Month for Given Date

Finds Start of the month with given date

CREATE  FUNCTION [dbo].[StartOfMonth]
(
  @date datetime
)

RETURNS datetime
AS
BEGIN
  return DATEADD(M,-1,DATEADD(mm, DATEDIFF(m,0,@date)+1,0))
END
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

2 Responses to Find Start of a Month for Given Date

  1. Nick says:

    Why do a need a function for this? You can do this using a calculated field. 🙂

  2. admin says:

    HRNET calculated field does not allow this function stright away, you need to write this in the field anyway.

    Anyway, I used this function not in HRNET, but in SQL Server procedures, in the background.

Leave a Reply to Nick Cancel reply

Your email address will not be published. Required fields are marked *