Is there any date function available to get the last date of a month.
If not , How can I get it ?Hi, Sha
Use one of the following functions:
CREATE FUNCTION dbo.LastDayOfTheMonth(@.TheDate datetime)
RETURNS datetime AS
BEGIN
RETURN DATEADD(month, DATEDIFF(month, 0, @.TheDate) + 1, 0) - 1
END
CREATE FUNCTION dbo.LastDayOfTheMonth(@.TheDate datetime)
RETURNS datetime AS
BEGIN
RETURN DATEADD(month, 1, CONVERT(varchar(6), @.TheDate, 112) + '01') - 1
END
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment