BOMONTH (TSQL Function)
Returns the first day of the month of the specified date. An optional month offset can be added to the date argument.
Syntax
BOMONTH ( date [, months_offset] )
Arguments
- date
- is a date expression of type
date
ordatetime
. - months_offset
- optional number of months to add to date, of type
int
. Default is 0.
Return Types
Returns same type as date argument.
Remarks
This function doesn’t exist in MS SQL Server.
Examples
DECLARE @d DATETIME = '2015-02-10';
PRINT BOMONTH(@d, 1);
PRINT BOMONTH(@d);
PRINT BOMONTH(@d, -1);
The result is:
2015-03-01 00:00:00
2015-02-01 00:00:00
2015-01-01 00:00:00