Thursday, 15 July 2010

tsql - How to get dates that are due for the following month from a column -



tsql - How to get dates that are due for the following month from a column -

i want bring dates in column (nexteventdate) dates due next month.

can please advise how in t-sql?

this give due dates.

declare @events table ( eventid int identity(1,1), eventname nvarchar(100), startdate date, enddate date ) insert @events values ('name1','11/01/2014','11/02/2014'), ('name2','09/13/2014','09/15/2014'), ('name3','11/02/2014','11/03/2014'), ('name4','09/14/2014','09/17/2014') select * @events convert(nvarchar,getdate(),111) < startdate

this give month start date:

select substring(convert(nvarchar,startdate),6,2) startdatemonth,* @events

this give current motnh:

select substring(convert(nvarchar,getdate(),111),6,2)

tsql

No comments:

Post a Comment