date range

  • Here is a sample of my data and this is the query I wrote to get it:

    select a.custid, a.custname, b.invoiceduedays, c.invoicedate, c.invoiceno

    from tcustomer a

    join tcustprod b on a.custkey = b.custkey

    join tacctrecv c on a.custkey = c.custkey

    custid custname invoiceduedays invoicedate invoiceno

    ---------- ------------------------------ -------------- ---------------- -----------------

    10025 ANCHOR IN 0 2006-04-27 00:00:00.000 118607

    10025 ANCHOR IN 0 2006-06-15 00:00:00.000 121296

    10025 ANCHOR IN 0 2007-02-15 00:00:00.000 133628

    10025 ANCHOR IN 0 2006-04-27 00:00:00.000 118607

    Now I want to add -----Where invoicedate is older than 6 months from todays date.

    How would i complete this query?

    Thank you

  • where c.invoicedate < dateadd( month, -6, getdate() )

    btw, the subtitle for your post was "Find invoice dates over 30 days old". to do that, use dateadd( day, -30, getdate() ).

  • Thank you soooo much. It worked! 🙂

    I have been trying to figure that out. I appreciate it very much!

    I love this site!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply