Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting next month's Data based on parameter field

Status
Not open for further replies.
Dec 11, 2009
60
US
I have 2 parameters I am passing in and they are being used as below:

@start = '2010-03-01'
@end = '2010-03-31'.

sum(case when o.startdate between @start and @end then originalopenings else 0 end) as newopenings,

now I need to create another formula but this time I want the ones with start date for the next month based on the current parameter values being passed in?
--o.startdate between '2010-04-01' and '2010-04-30'

How can I incorporate that into a formula?
 
You could use DateAdd() to increment the variables.

Beir bua agus beannacht!
 
I can increment @start as dateadd(mm,1,@start) and get the correct value, but how do I get the end of the next month considering that march has 31 days and April has 30 days?

That is where my issue comes in at, figuring out the formula for @end?

Thanks,
 
If I enter 4/30/2010 as @end the value returned is 5/30/2010 and there are 31 days in May?
 
Which solution are you referring to?

Beir bua agus beannacht!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top