select date in range

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mareza
    New Member
    • Dec 2012
    • 1

    select date in range

    hello

    i have two tables, racuni and putninalog, in table racuni i have field Date and in table putni nalog startdate and enddate. so i need query that will show me all fields drom table racuni and few fileds from table putninalog only if Date is between startdate and enddate.

    thanks
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    You have very general question thus the best I can answer is that you need two select queries (or you can do in one) wherein they are joined on the correct field and with the given constraints.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      You either need to JOIN the two tables together ON the criteria, or JOIN them and use the WHERE clause to specify which records to include. Access cannot handle tables which are JOINed other than by [Field]=[Field] in its graphical display, but it will store it for you as SQL.
      1. Code:
        SELECT tR.*
             , tP.*
        FROM   [Racuni] AS tR
               INNER JOIN
               [Putninalog] AS tP
          ON   tR.Date Between tP.StartDate And tP.EndDate
      2. Code:
        SELECT tR.*
             , tP.*
        FROM   [Racuni] AS tR
             , [Putninalog] AS tP
        WHERE  (tR.Date Between tP.StartDate And tP.EndDate)

      Typically A would be more efficient, but the difference it makes depends on various issues we know nothing about so I'll leave that with you.

      Comment

      Working...