"Nat Johnson" <NatJohnson@discussions.microsoft.com> wrote in message
news:EC35E742-025D-4532-9BC9-DE4C42292816@microsoft.com...
> Thanks for the help. Not quite right tho. I need to return all enddates
> that are within the last six months or that are null.
>
> RUnning this returns all enddates - 6 months.
> I dont want to change the value of the enddate.....just return enddates that
> have occurred during the last 6 months.
>
> ie. getdate(todays date) - 6 months
>
>
> "Dan Christjohn" wrote:
>
>> and (rpn.enddate > datediff(mm,-6,rpn.enddate))
>>
>> That will subtract six months from rpn.enddate. Here is the msdn ref link:
>>
>>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp
>>
>> Good luck!
>>
>> Peace,
>>
>> Dan
>>
>>
>> "Nat Johnson" <NatJohnson@discussions.microsoft.com> wrote in message
>> news:FC3E4789-C18E-491F-B845-A71E5696EA19@microsoft.com...
>> > Have asked previous but not helped...so thought I would give it another
>> > go.
>> > I have a query with a number of inner joins and left outer joins. The
>> > where
>> > clause has numerous "and" clauses and one of these I need to be where a
>> > endate is greater than the current date less 6 months (ie anything in the
>> > last six months).
>> >
>> > where (a.DeletedDate IS NULL) and (stli.id = 1) and (fa.regionareaid
>> > between
>> > 1 and 9)
>> > and (rpn.enddate > '01/01/2005') or (rpn.enddate is null)
>> >
>> > at present as you can see I have stipulated the date as 01/01/2005 however
>> > i
>> > need the report to run every week (schedule will be set up for running and
>> > emailing) and I need the report to have the correct "and" in place. Any
>> > help
>> > would be greatly appreciated. the rpn.enedate can either have a date or
>> > be
>> > null.
>> >
>> > hopefully this is a bit more information.
>>
>>
>>