Show past 3 years

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BerkshireGuy

    Show past 3 years

    I need a query to include a field called SettlementDate.

    When the user runs the query, I need to prompt for "Enter Year" and
    show the last three years of SettlementDate.

    Can seem to get the logic down.

    Thanks
  • Salad

    #2
    Re: Show past 3 years

    BerkshireGuy wrote:
    I need a query to include a field called SettlementDate.
    >
    When the user runs the query, I need to prompt for "Enter Year" and
    show the last three years of SettlementDate.
    >
    Can seem to get the logic down.
    >
    Thanks
    I tried this SQL
    SELECT ID, DateEntered, Year([DateEntered]) AS Expr1
    FROM Table1
    WHERE Year([DateEntered] Between [Enter Year] And [Enter Year]+2;

    Seemed to work.

    Dirty

    Comment

    • BerkshireGuy

      #3
      Re: Show past 3 years

      Thanks - I was just going to post that I did:

      SQL Select Year(Settlement DecisionDT) ...... ....
      FROM Mytable
      Where
      Year([SettlementDecis ionDT]))>=[Enter Year]-3));

      So basic. Coffee hadn't kicked in. :)

      Thanks

      On Mar 24, 11:12 am, Salad <o...@vinegar.c omwrote:
      BerkshireGuy wrote:
      I need a query to include a field called SettlementDate.
      >
      When the user runs the query, I need to prompt for "Enter Year" and
      show the last three years of SettlementDate.
      >
      Can seem to get the logic down.
      >
      Thanks
      >
      I tried this SQL
      SELECT ID, DateEntered, Year([DateEntered]) AS Expr1
      FROM Table1
      WHERE Year([DateEntered] Between [Enter Year] And [Enter Year]+2;
      >
      Seemed to work.
      >
      Dirtyhttp://www.youtube.com/watch?v=JjQ4Smp tIyQ

      Comment

      • Bob Quintal

        #4
        Re: Show past 3 years

        BerkshireGuy <berkshireguy20 05-commerical@yaho o.comwrote in
        news:13b0ebce-7c2f-452e-9eb6-
        60b0fa50622c@t5 4g2000hsg.googl egroups.co
        m:
        Thanks - I was just going to post that I did:
        >
        SQL Select Year(Settlement DecisionDT) ...... ....
        FROM Mytable
        Where
        Year([SettlementDecis ionDT]))>=[Enter Year]-3));
        >
        So basic. Coffee hadn't kicked in. :)
        It won't work when you enter a date 4 or more years ago. You'll get
        the three years you want plus all the more recent data
        >
        Thanks
        >
        On Mar 24, 11:12 am, Salad <o...@vinegar.c omwrote:
        >BerkshireGuy wrote:
        I need a query to include a field called SettlementDate.
        >>
        When the user runs the query, I need to prompt for "Enter Year"
        and show the last three years of SettlementDate.
        >>
        Can seem to get the logic down.
        >>
        Thanks
        >>
        >I tried this SQL
        >SELECT ID, DateEntered, Year([DateEntered]) AS Expr1
        >FROM Table1
        >WHERE Year([DateEntered] Between [Enter Year] And [Enter Year]+2;
        >>
        >Seemed to work.
        >>
        >Dirtyhttp://www.youtube.com/watch?v=JjQ4Smp tIyQ
        >
        >


        --
        Bob Quintal

        PA is y I've altered my email address.

        --
        Posted via a free Usenet account from http://www.teranews.com

        Comment

        Working...