+ Reply to Thread
Results 1 to 6 of 6

Thread: Working with Time and Date

  1. #1
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Question Working with Time and Date

    Hi,

    I have to perform several different calculations using time and date, and am more confused after searching through forums and help files.

    On my excel worksheet there is a cell that will feature start date/time. I need to calculate start time + 24 hours, 48 hours and 72 hours, and be able to display the date and times in another cell.

    Once I'm done with those calculations I will need to go back 7 days from current date/time, and add up the total amout of time in days and hours between each start/end times withing those 7 days.

    I'm not sure if it would be easier to do this with formulas on the worksheet, or in vba

    Soma

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,056

    Re: Working with Time and Date

    I'm not clear on the second requirement but adding hours to a date is quite simple with formulas. If you have a date/time in A1 you can add 48 hours like this

    =A1+"48:00"

    but if you are always adding multiples of 24 hours it's simpler to do the same like this

    =A1+2

    those two both give the same result because in Excel 1= 1 day = 24:00

  3. #3
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Working with Time and Date

    Thanks Daddy,

    That's so much simpler that what I've been seeing online.

    My second requirement is a little more complicated. In a 7 days period (168 hours going backwards from current date/time) I need to find entries where the start date falls within the past 168 hours.

    For example

    Feb 4, 2010 - start time, 08:00 - end time, 14:00
    Feb 7, 2010 - start time, 13:00 - end time, 17:00
    Feb 10, 2010 - start time, 09:30 - end time, 16:45

    Going back 168 hours from now, the first entry on Feb 4 falls outside the period I'm looking at and can ignore. What I need is to be able to add 4 hours on Feb 7th to 7:45 hours on Feb 10. Therefore, in the past 7 days (168 hours) there is a total time of 11:45 hours.

    Hopefully I've explained that well

    Soma

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Working with Time and Date

    Are your dates, beginning times and ending times in 3 different columns? If so,
    =SUMPRODUCT(--(NOW()-($A$2:$A$500)<7),($C$2:$C$500-$B$2:$B$500))
    Format the cell >number >custom [hh]:mm Does that work for you?
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  5. #5
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Working with Time and Date

    Thanks Chemist,

    It wasn't exactly what I was looking for as my data is in rows, but it all helps.

    I think what I may do is have another colum with all the time elapsed for each row and then write a long if statement to select which ones to use.

    I do have another question though.....

    I've used the following formula to determine the elapsed time between start and end date

    =24*(IF(B3>G3,G3+1-B3,G3-B3))

    The entry that I'm working on is 3 days, 5 hours. The result I'm getting from the formula is 53 hours. How can I get it to show "3 days, 5 hours"

    Soma

  6. #6
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,770

    Re: Working with Time and Date

    That formula is intended for applications when the interval may be overnight, but less than 24 hours (e.g., timecards).

    For intervals up to 31 days, just =G3-B3 and format as d "days" h "hours"
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ 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.2.0