Results 1 to 2 of 2
  1. #1
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57

    Question Compare Day and Time to output result based on criteria

    I have a database which records faults and also use of company vehicles for that fault. i have a drop down list for vehicle registration and added option of private/ public transport/ Not applicable. I would like to monitor faults that require vehicles to be used after business hours.



    Business hours are monday to thursday 8 am - 4.30pm and Friday 8am - 4pm. I would like to check if fault occurs after this hours and if a vehicle was used, display on a separate field "outside working hours" for that particular record. I would also like to monitor faults that use vehicles that start within business hours but are not completed within business hours.

    i tried a very basic code to compare time, which did not take into regard which day it was or if vehicle was used or not.

    Code:
    me.vehicleuse= iif(# 8:00:00 am # < [Date_fault_lodged] > # 4:30:00 pm #, "outside working hours", "")

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    you need to provide some examples of your data - you appear to be comparing dates and times.

    And your formula is incorrect - assuming (despite its name) [Date_fault_lodged] is actually a time, try

    iif(# 8:00:00 am # < [Date_fault_lodged] OR [Date_fault_lodged] > # 4:30:00 pm #, "outside working hours", "")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 12-20-2017, 09:45 PM
  2. Replies: 2
    Last Post: 06-16-2017, 04:27 PM
  3. Replies: 3
    Last Post: 08-03-2015, 06:12 PM
  4. Replies: 5
    Last Post: 05-28-2015, 06:58 AM
  5. Replies: 1
    Last Post: 08-14-2012, 03:22 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums