How to create function which return month April to march in given year.
like :
Apr-19
May-19
Jun-19
Jul-19
Aug-19
Sep-19
Oct-19
Nov-19
Dec-19
Jan-20
Feb-20
Mar-20
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Aug 30, 2019, 4:53 AM
Sonu GuptaPosted Aug 30, 2019, 1:35 AM
Sohil AhmedPosted Aug 30, 2019, 12:52 AM
Nitin SontakkePosted May 20, 2019, 12:15 AM
Nitin SontakkePosted May 17, 2019, 10:37 PM
Sohil AhmedPosted May 15, 2019, 4:48 AM
@dateFrom datetime,
@dateTo datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @records table
(
[ArrivalDate] datetime not null
)
declare @dateIndex datetime = @dateFrom
while @dateIndex <= @dateTo
begin
select @dateIndex = dateadd(MONTH, 1, @dateIndex)
insert into @records select @dateIndex
end
select r.ArrivalDate
from @records r order by r.ArrivalDate asc
END