Hi Friends,
I have 2 display month between 2 dates
For eg.I have StartDate=1/1/2011 and EndDate=15/5/2011
It will display me:
January February March April May
Loading
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.
Manikavelu VelayuthamPosted Feb 3, 2011, 2:31 AM
FLOAT
F1: BEGIN ATOMIC
RETURN 12 * (year(d1) - year(d2)) + month(d1)- month(d2) + ( TIMESTAMPDIFF(2, CHAR(d1 - (d2 + (12*(year(d1) - year(d2)) + month(d1) - month(d2)) MONTHS))) / 2678400.0 );--
END@
SELECT dbo.months_between(firstdate, seconddate)
Above will return the months between the two dates.
ShankeyPosted Feb 3, 2011, 2:29 AM
Hope this will help you,
Declare
@sd date,
@ed date
begin
set @sd=CONVERT(date,'1/1/2011');
set @ed=CONVERT(date,'5/15/2011');
while (@sd < @ed)
begin
SELECT DATENAME(month, @sd)
SET @sd = DATEADD(MONTH,1,@sd);
End
End
Thanks,
Shankey