How to query for an interval between 18 and 6 (hours, as integer in the table)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cocea Razvan
    New Member
    • Feb 2011
    • 3

    How to query for an interval between 18 and 6 (hours, as integer in the table)?

    Dear all,

    Probably this is a stupid question but I'm new to access.
    I am trying to select from "Ora" column in the table (picture attached) values between 18 and 6. All my filtering works until here. "Ora" is defined as integer, data is inserted into the table by an external app. I cannot modify this field as the external app cannot send the date/time in a different format.

    Istoric_Turnari - the table that i am trying to query
    Forms!Rap_Tura! An_cal - the selected year inside Rap_Tura form
    etc etc

    I am trying this(one of the many sollutions that I tried):

    SELECT *
    FROM Istoric_Turnari IN 'C:\Istoric.mdb '
    WHERE Istoric_Turnari .An=Forms!Rap_T ura!An_cal And Istoric_Turnari .zi Between 7 And 8 And Istoric_Turnari .ora>=18 And Istoric_Turnari .ora<=6;
    Attached Files
  • orangeCat
    New Member
    • Dec 2007
    • 83

    #2
    Istoric_Turnari .ora>=18 And Istoric_Turnari .ora<=6;

    I don't think this is possible,
    What can be greater or equal 18 AND Less than or equal 6

    Do you mean
    Istoric_Turnari .ora>=6 And Istoric_Turnari .ora<=18

    Note you could use the Between operator. In Access it includes endpoints.

    Comment

    • Cocea Razvan
      New Member
      • Feb 2011
      • 3

      #3
      I got it!

      Thanks orangeCat for your quick reply.
      Actually what I wanted to do was to select from the table the batches feeded between 19:00 hrs to 7:00 (The night shift). For the day shift it was easy, using "between 7 and 19".
      Following I am posting the "winning formula", if someone ever bumps into this. It's tested and working well. I hope it makes sense, as it uses form data.

      SELECT *
      FROM Istoric_Turnari IN 'C:\Istoric.mdb '
      WHERE Istoric_Turnari .An=Forms!Rap_T ura!An_Cal
      And
      ((Istoric_Turna ri.Zi=Forms!Rap _Tura!Zi_Cal
      and
      Istoric_Turnari .ora>=Forms!Rap _Tura!Inc_Sch)
      Or
      (Istoric_Turnar i.Zi=Forms!Rap_ Tura!ZiSc2
      and
      Istoric_Turnari .ora<=Forms!Rap _Tura!Sf_Sch));

      Comment

      • Cocea Razvan
        New Member
        • Feb 2011
        • 3

        #4
        As a legend:
        Zi_Cal - the selected day
        Inc_Sch - Shift start hour
        ZiSc2 - the selected day +1 (day in which the shift ends)
        Sf_Sch - Shift end hour

        Comment

        Working...