Date problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swanny
    New Member
    • Jun 2007
    • 4

    #1

    Date problems

    Hi

    I am trying to search for records after a certain date,new to code and require pointing in the right direction.


    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by swanny
    I am trying to search for records after a certain date,new to code and require pointing in the right direction.
    Can you give us some idea of the circumstances? Is there a database involved somehow? Are you using Visual Basic? What version? How are you conecting the the database (if any)?

    Comment

    • swanny
      New Member
      • Jun 2007
      • 4

      #3
      Hi Killer42

      Sorry 1st post

      I've taken over a work database and it has a access 2002 database sheet with a vb 6 front end.

      The line off code is:

      Code:
      rs.Open "SELECT * FROM JobBook WHERE bookedby = 'Alex'  AND status <> 'Cancelled' AND status <> 'completed' AND status <> 'Recalled' AND status <> 'Recall' AND status <> 'Recall - in Progress' AND printed = false ORDER BY DateWorksReq", cn, adOpenDynamic, adLockPessimistic
      i want to remove the "bookedby = "alex" which is ok,but need to start the code checking from a fixed date onwards (date not to change) this is all working from a button!

      Hope this is enough...thanks for your time

      Comment

      • cmrhema
        Contributor
        • Jan 2007
        • 375

        #4
        Originally posted by swanny
        Hi Killer42

        Sorry 1st post

        I've taken over a work database and it has a access 2002 database sheet with a vb 6 front end.

        The line off code is:

        Code:
        rs.Open "SELECT * FROM JobBook WHERE bookedby = 'Alex'  AND status <> 'Cancelled' AND status <> 'completed' AND status <> 'Recalled' AND status <> 'Recall' AND status <> 'Recall - in Progress' AND printed = false ORDER BY DateWorksReq", cn, adOpenDynamic, adLockPessimistic
        i want to remove the "bookedby = "alex" which is ok,but need to start the code checking from a fixed date onwards (date not to change) this is all working from a button!

        Hope this is enough...thanks for your time
        If you are not going to change the date then write down
        [HTML]WHERE bookedby = #01/01/2001# AND [/HTML]
        in case you want to change date then
        [HTML]WHERE bookedby = # " & dtpicker.value & "# AND [/HTML]
        here dtpicker is the control where you display date

        Check out and see

        Comment

        • swanny
          New Member
          • Jun 2007
          • 4

          #5
          Originally posted by cmrhema
          If you are not going to change the date then write down
          [HTML]WHERE bookedby = #01/01/2001# AND [/HTML]
          in case you want to change date then
          [HTML]WHERE bookedby = # " & dtpicker.value & "# AND [/HTML]
          here dtpicker is the control where you display date

          Check out and see
          the column in the database is date...so
          Code:
          WHERE date = #01/01/2001#  AND
          Nothing happening...i need it for the date stated to the present,what do the # symbols do?

          sorry to be a pain!

          Comment

          • cmrhema
            Contributor
            • Jan 2007
            • 375

            #6
            Originally posted by swanny
            the column in the database is date...so
            Code:
            WHERE date = #01/01/2001#  AND
            Nothing happening...i need it for the date stated to the present,what do the # symbols do?

            sorry to be a pain!
            First of all let me clarify that you are using Visual Basic 6 as front end and the backend in MS ACCESS 2002
            Secondly "#" is used to retrieve Date values from ACCESS and ' is used for SQL SERVER
            I still do not know the reason you do not get the answer.
            Kindly post the code once again
            Thanks

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by cmrhema
              ...I still do not know the reason you do not get the answer.
              Actually, it's quite simple. You said to retrieve records with one specific date. You should use > rather than =.

              Comment

              Working...