title: Date ranges in SQL select query
body: <p>My SQL database performs a backup of all records from an Access database daily, indicating the backup time with the field 'Logtime' (formatted as datetime). The point of my SQL database is to store all versions of my Access database records. For example, if an entry in the Access database is changed, I can see all versions of the entry in SQL and determine what was changed and when. I am using the query below to select records from my SQL database, but it only works with one date at a time. Because the field 'Logtime' acts as a unique identifier to pull records together, I am uncertain how to query a date range without pulling erroneous duplicate records. I would greatly appreciate any assistance the community can provide. Please let me know if I can clarify my question in any way.</p>
  
  <pre><code>DECLARE @theDate varchar(60)
  SET @theDate = '10/31/2018'
  
  SELECT        dbo.tbl_EquipmentRequests.Logtime, dbo.tbl_EquipmentRequests.[Equipment Request ID], dbo.tbl_EquipmentRequests.[TrackIT Number], dbo.tbl_EquipmentRequests.[Requestor name:], 
                           dbo.tbl_EquipmentRequests.[Requestor email:], dbo.tbl_EquipmentRequests.[Entered on:], dbo.tbl_EquipmentRequests.[Approver name:], dbo.tbl_EquipmentRequests.[Approver email:], 
                           dbo.tbl_EquipmentRequests.Status, dbo.tbl_EquipmentRequests.Notes, dbo.[tbl_IT Staff].[IT Staff Member], dbo.tbl_Order_Types.[Order Type], dbo.tbl_EquipReqDetails.Vendor, dbo.tbl_EquipReqDetails.Quantity, 
                           dbo.tbl_EquipReqDetails.[Unit Price], dbo.tbl_EquipReqDetails.[Account Code], dbo.tbl_EquipReqDetails.Status AS Expr1, dbo.tbl_EquipReqDetails.[Vendor Invoice #], 
                           dbo.tbl_EquipReqDetails.[Invoice approved by Tom], dbo.tbl_EquipReqDetails.[Invoice date], dbo.tbl_EquipReqDetails.[Invoice sent to AP on], dbo.tbl_EquipReqDetails.Notes AS Expr2, 
                           dbo.tbl_Equipment.[Equipment Description]
  FROM            dbo.tbl_EquipmentRequests INNER JOIN
                           dbo.[tbl_IT Staff] ON dbo.tbl_EquipmentRequests.[Entered by:] = dbo.[tbl_IT Staff].ID INNER JOIN
                           dbo.tbl_Order_Types ON dbo.tbl_EquipmentRequests.[Order Type] = dbo.tbl_Order_Types.ID INNER JOIN
                           dbo.tbl_EquipReqDetails ON dbo.tbl_EquipmentRequests.[Equipment Request ID] = dbo.tbl_EquipReqDetails.[Equipment Request ID] INNER JOIN
                           dbo.tbl_Equipment ON dbo.tbl_EquipReqDetails.[Equipment ID] = dbo.tbl_Equipment.ID
  WHERE        (CAST(dbo.tbl_EquipmentRequests.Logtime AS date) = @theDate) AND (CAST(dbo.[tbl_IT Staff].Logtime AS date) = @theDate) AND (CAST(dbo.tbl_Order_Types.Logtime AS date) = @theDate) AND 
                           (CAST(dbo.tbl_EquipReqDetails.Logtime AS date) = @theDate) AND (CAST(dbo.tbl_Equipment.Logtime AS date) = @theDate)
  </code></pre>