+ Reply to Thread
Results 1 to 3 of 3

Calculating a previous work shift time (05:30, or 17:30) based on current time

  1. #1
    Registered User
    Join Date
    09-19-2017
    Location
    london, england
    MS-Off Ver
    MS 2003
    Posts
    2

    Calculating a previous work shift time (05:30, or 17:30) based on current time

    I am trying to set a specific start DateTime, and end DateTime based on the current time. At work, day shift work 05:30 in the morning till 17:30 in the evening. Then night shift start at 17:30 and work until 05:30 the next morning.

    Based on the current time, I want to describe the start and end DateTime of the previous shift. For example if its 21/09/2017 08:40, the start and end Date Time is 20/09/17 17:30 and 21/09/2017 05:30 respectively. Another example, if it is 21/09/2017 16:00, the start and end Date Time is 20/09/17 17:30 and 21/09/2017 05:30 respectively again (still day shift). If the current time is 21/09/2017 20:50, the start and end Date Time is 21/09/17 05:30 and 21/09/2017 17:30 respectively.

    I have tried and cannot get it to work. Currently I have

    In Cell A1 i have =NOW()
    In Cell A2 =(INT(2*$A$1)/2)-0.5+0.2291667; [the minus 0.5 brings it to 6am or 6pm, and the 0.229 brings it back another 30min]
    IN Cell A3 =A2+0.5

    Right now my formula does not work after 12pm but I do not know how to change it. With the current formula if the time is 21/09/17 14:00, it calculates the Start DateTime as 21/09/2017 05:30, which is incorrect it should 20/09/17 17:30.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Calculating a previous work shift time (05:30, or 17:30) based on current time

    welcome to the forum, andrew. try this in A2:
    =IF(MOD(A1-TIME(5,30,0),1)<=--"12 pm",INT(A1)-1+TIME(17,30,0),INT(A1)+TIME(5,30,0))

    your A3 formula can retain

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    09-19-2017
    Location
    london, england
    MS-Off Ver
    MS 2003
    Posts
    2

    Re: Calculating a previous work shift time (05:30, or 17:30) based on current time

    Thank you so much Benishiryo, I appreciate it and will mark this thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 06-10-2016, 11:38 PM
  2. Replies: 10
    Last Post: 11-08-2014, 04:51 PM
  3. Replies: 4
    Last Post: 09-24-2013, 11:32 AM
  4. Replies: 16
    Last Post: 12-06-2012, 12:18 PM
  5. Calculating shift end time with meals
    By dsmout in forum Excel General
    Replies: 8
    Last Post: 10-08-2012, 03:21 PM
  6. Calculating END time based on start time, breaks, and hours to complete
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2012, 11:29 AM
  7. Calculating work time when end time is after midnight.
    By dpatchie in forum Excel General
    Replies: 1
    Last Post: 02-01-2012, 11:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1