This is about a stored procedure I'm working on. I have a field which gives me a value of datetime type. I need to display the 6 months starting from the month in the field. E.g. field gives me Feb, I have to display Feb, Mar,April, May, June, July seperately. And if the months reach December I have to increase the value of the year. Can anyone help?

here ya go, parts you will need to change are in all capitals.
I'm not an SQL genius so there may be a better way to do this, but this works.

create proc daterange (@inputdate datetime)
as
declare @startdate datetime

set @startdate = cast((substring(cast(@inputdate as varchar(11)),1,3)+' '+ substring(cast(@inputdate as varchar(11)),8,4))as datetime)
select * from TABLENAME where DATEFIELD >= @startdate and DATEFIELD < dateadd(month,6,@startdate)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.