Home All Groups Group Topic Archive Search About

Select Statement based on Date Criteria

Author
22 Sep 2005 4:49 PM
Leslie
I am trying to extract data based on the following:

Select * from table
where datefield < OneMonthAgo

WHen I try the DATEADD, it gives me everything from one month ago to today. 
I want everything on the other side of one month ago.

This is what I currently have
select custid, billname, crtd_DateTime, OrdDate, status, cancelled, * from
soheader
where soTypeID = '200' and (OrdDate < DateAdd(mm, -1, GETDATE()))

Cheers,
Leslie

Author
22 Sep 2005 5:43 PM
Leslie
Never Mind, they syntax below IS correct!!!  I was using old data and, well,
I was confused! :O)

Cheers,
Leslie

Show quote
"Leslie" wrote:

> I am trying to extract data based on the following:
>
> Select * from table
> where datefield < OneMonthAgo
>
> WHen I try the DATEADD, it gives me everything from one month ago to today. 
> I want everything on the other side of one month ago.
>
> This is what I currently have
> select custid, billname, crtd_DateTime, OrdDate, status, cancelled, * from
> soheader
> where soTypeID = '200' and (OrdDate < DateAdd(mm, -1, GETDATE()))
>
> Cheers,
> Leslie

AddThis Social Bookmark Button