November 7, 2012 at 12:55 pm
I'm new to being a DBA, and to SQL in general with only about 4 months experience. I am currently writing a proc that has two parameters, @StartDate and @EndDate. I need to be able to limit the maximum date range to 6 months.
WHERE TransactionDateTime >= @Startdate
and TransactionDateTime < DATEADD(day,1,@Enddate)
and TransactionDateTime < DATEADD(month,6,@StartDate)
Am I on the right track here? My logic behind this is that obvs it has to be greater than the start date, and less then the enddate +1 day. The last part of the statement my thinking was that it has to be less then 6 months forward of @StartDate. Ideas?
November 7, 2012 at 1:17 pm
Update. That code works to an extent to the point that it will only return up to 6 months ahead of @StartDate if my range is longer than that, but I need to not return any results at all if they go over that 6 month range.
November 7, 2012 at 8:06 pm
Really can't help you based on what you have posted as there is simply not enough information. We can't see what you see from here.
Please take the time to read the first article regarding asking for help I reference below in my signature block. The article will show you what you need to post and how to post it to get the best possible answers.
Also, be sure to post your expected results based on the sample data you will post.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply