0
私はこの機能を実行することはできませんよ、この中に変更があります:mysqlで前月の最初の日付を見つけるのに役立つ人がいますか?
select subdate(adddate(last_day(now()), 1), interval 2 month)
はとnow()
を交換する:あなたが "今" に、それは相対したいと仮定すると、
CREATE FUNCTION [GetFirstDateofMonth]
(@Date as DateTime)
RETURNS DateTime AS
BEGIN
Declare @FirstDate DateTime
Set @FirstDate = DateAdd(Day, 1, @Date - Day(@Date) + 1) -1
RETURN @FirstDate
END
CREATE FUNCTION [GetLastDateofMonth]
(@Date as DateTime)
RETURNS DateTime AS
BEGIN
Declare @LastDate DateTime
Set @LastDate = DateAdd(Month, 1, @Date - Day(@Date) + 1) -1
RETURN @LastDate
END