Results 1 to 2 of 2
  1. #1
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40

    Subtract break and lunch time when Time Calculation past midnight

    Hi,

    I hope someone can help me on this, I have two shifts, 1st Shifts 6 am to 6 pm, and 2nd Shift 6 pm to 6 am. I have no problem subtracting from the 1st shift break/lunch times. It's when I'm trying to subtract from the 2nd shift which goes past midnight.


    2nd Shift 1st Break is from 8:30:00 PM to 8:45:00 PM / Lunch 12:00:00 AM to 12:30:00 AM / 2nd Break 3:00:00 AM to 3:15:00 AM

    Fields in my Access query:

    1stBreak
    : IIf(([StartTime]<=#8:30:00 PM# And [EndTime]>=#8:45:00 PM#),15,0)
    Lunch: IIf(([StartTime]<=#12:00:00 AM# And [EndTime]>=#12:30:00 AM#),30,0)
    2ndBreak: IIf(([StartTime]<=#3:00:00 AM# And [EndTime]>=#3:15:00 AM#),15,0)

    It only happens when I pass midnight between StartTime and EndTime as you can see below? The user can start and end a job at 11 pm to 6 am. I want to get it to add the break time depending on the StartTime and EndTime?

    Not adding break and lunch time in RED
    StartTime EndTime 1stBreak Lunch 2ndBreak
    8:30 PM 8:50 PM 15 0 0
    12:00 AM 12:35 AM 0 30 0
    3:00 AM 3:20 AM 0 0 15
    6:00 PM 6:00 AM 0 0 0
    8:30 PM 3:15 AM 0 0 0
    6:00 PM 12:00 AM 0 0 0
    11:00 PM 6:00 AM 0 0 0


    This is how I would like it to adding break and lunch time in BLUE


    StartTime EndTime 1stBreak Lunch 2ndBreak
    8:30 PM 8:50 PM 15 0 0
    12:00 AM 12:35 AM 0 30 0
    3:00 AM 3:20 AM 0 0 15
    6:00 PM 6:00 AM 15 30 15
    8:30 PM 3:15 AM 15 30 15
    6:00 PM 12:00 AM 15 0 0
    11:00 PM 6:00 AM 0 30 15


    I hope someone can help? I've tried everything I could think of?

    Thanks,
    Xavier Ramirez

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    date and time is stored as a decimal number - the bit before the decimal point represents the date, where 31/12/1899 is zero, 1/1/1900 is 1 and counting up to the present day and beyond. The bit after the decimal point represents the time and is expressed as the time in seconds divided by 86400 (the number of seconds in a day).

    What you see as a date and/or time is just a format, it is not the value.

    So given that information, you need to check what your actual values are. You can do so by using the cdbl function. Cdbl(mydate) with return a decimal number. So if you are trying to add 15 to a time, you are adding 15 days, not minutes.

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

Similar Threads

  1. Calculating over time across midnight issues
    By ewilson378 in forum Forms
    Replies: 7
    Last Post: 10-18-2015, 04:13 AM
  2. Trying not to Schedule Classes around Lunch Time
    By boywonder381 in forum Programming
    Replies: 3
    Last Post: 09-12-2014, 03:43 AM
  3. Time Difference When Past Midnight
    By StevenCV in forum Access
    Replies: 5
    Last Post: 01-30-2014, 08:05 AM
  4. Calculating time AT midnight
    By atom in forum Queries
    Replies: 11
    Last Post: 02-05-2012, 04:27 PM
  5. Date/Time Search Midnight Issue
    By Coffee in forum Queries
    Replies: 5
    Last Post: 07-26-2011, 01:54 AM

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