Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    4

    Question Unanswered: Start Time Query

    I have several thousand records in a database broken down into groups of "workflows" Each workflow has an alllowed Start Time and an Allowed Stop Time. ex. 06:00 AM 04:00 PM. When a user logs into the application in the morning I want to make sure that they are not trying to open 08:00 am work at 06:00 AM. I have tried using a query saying if NOW() < Allowed Start Time do not open that workflow. If NOW() > Allow start time, open the workflow.
    So far, I cannot make this work. Any suggestions would be welcome. I am using Access 2003.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Now() contains a date component.

    Now() = 29 June 2009 @ 10:19am has a value, something like 84883.28238 (number of days since 31/12/1899). A simple time such as your field is only a time (value, such as 0.23738). Therefore Now() is always going to evaluate higher.

    If you use Int(Now()), then it removes the date component.

    Try that
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Try putting both Now() and Allowed Start Time into variables which are formatted the same way and then do the compare.

    ie..

    Dim NowDate as Date
    Dim AStartTime as date
    NowDate = Format(Date(),........
    AStartDate = Format(AllowStartDate,........

    Use expressions (ie. Exp: Format(AllowStartDate,........)) for queries. Or run your compare code against the variables. If doing it in a query make sure the date used in the criteria row is also in the same format.
    Last edited by pkstormy; 06-29-09 at 00:06.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Oct 2004
    Posts
    4
    IF ALLOWSTARTTIME > NOW() NOT OK

    iF ALLOWSTARTTIME< NOW() OK

    STILL NOT WORKING????

  5. #5
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    How about IF ALLOWSTARTTIME > Format(Now(),"short time") assuming your ALLOWSTARTTIME is in the format HH:MM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •