+ Reply to Thread
Results 1 to 7 of 7

Help with time duration formula..

Hybrid View

amper Help with time duration... 12-27-2006, 03:23 PM
VBA Noob Hi, Would this help ... 12-27-2006, 03:34 PM
Bryan Hessey Hi, another option is to... 12-27-2006, 03:45 PM
amper EDIT~ =Q2-P2+(Q2<A2) ... 12-27-2006, 03:59 PM
Bryan Hessey =Mod( your calculation ,1) ... 12-27-2006, 06:48 PM
daddylonglegs You're using the wrong... 12-27-2006, 07:37 PM
amper thanks very much.. that was... 12-28-2006, 11:46 AM
  1. #1
    Registered User
    Join Date
    10-18-2006
    Posts
    5

    Help with time duration formula..

    Hi,

    i'm new to timesheets, but had a question regarding modifying the formula listed below:

    =Q2-P2+(Q2<A2)

    it works as intended for a time interval that crosses over midnight, but with any normal interval, an additional 24 hours is added to my duration.

    i'm attempting to use a single formula for all durations, so is there anyway to integrate an IF/THEN statement to subtract 24:00 hours if the calculated value is greater than 24:00?

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Would this help

    =IF(Q2<P2,P2-Q2,Q2-P2)

    Don't think you need A2 ??

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by amper
    Hi,

    i'm new to timesheets, but had a question regarding modifying the formula listed below:

    =Q2-P2+(Q2<A2)

    it works as intended for a time interval that crosses over midnight, but with any normal interval, an additional 24 hours is added to my duration.

    i'm attempting to use a single formula for all durations, so is there anyway to integrate an IF/THEN statement to subtract 24:00 hours if the calculated value is greater than 24:00?
    Hi,

    another option is to use

    =Mod( calculatedvalue ,1)

    hth
    ---
    Si fractum non sit, noli id reficere.

  4. #4
    Registered User
    Join Date
    10-18-2006
    Posts
    5
    EDIT~

    =Q2-P2+(Q2<A2)

    where:
    A2 = some date, say 12/10/2006
    P2 = 23:50
    Q2 = 01:10

    value would be 01:10, whereas using 01:00 and 02:00 would result in 25:00 instead of 01:00 that i'm aiming for. i'd still like to use a single formula for each duration cell (i'm putting together a form for mass usage). also, i'm not familiar with combining several arguments into one formula (apologies :x)
    Last edited by amper; 12-27-2006 at 06:10 PM.

  5. #5
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by amper
    EDIT~

    =Q2-P2+(Q2<A2)

    where:
    A2 = some date, say 12/10/2006
    P2 = 23:50
    Q2 = 01:10

    value would be 01:10, whereas using 01:00 and 02:00 would result in 25:00 instead of 01:00 that i'm aiming for. i'd still like to use a single formula for each duration cell (i'm putting together a form for mass usage). also, i'm not familiar with combining several arguments into one formula (apologies :x)
    =Mod( your calculation ,1)

    for you

    =Mod((Q2-P2+(Q2<A2)),1)

    ----

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697
    Quote Originally Posted by amper
    EDIT~

    =Q2-P2+(Q2<A2)

    where:
    A2 = some date, say 12/10/2006
    P2 = 23:50
    Q2 = 01:10
    You're using the wrong formula

    Assuming Q2 just contains a time and A2 a date then Q2 will always be less than A2 so your formula is the same as

    =Q2-P2+1, which, as you've discovered, will give you the wrong result whenever the shift doesn't cross midnight.

    You should use

    =Q2-P2+(P2>Q2)

    or

    =MOD(Q2-P2,1)

  7. #7
    Registered User
    Join Date
    10-18-2006
    Posts
    5
    thanks very much.. that was much cleaner than all the round about ways i thought up. cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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