+ Reply to Thread
Results 1 to 4 of 4

To automate Calculation of time taken

  1. #1
    Registered User
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    81

    To automate Calculation of time taken

    I have 2 cells with Date and time each

    Cell A1 :2/11/2014 12:05:00 PM . I need to subtract the time from 6 PM same day. which gives me 5 hours 55 minutes.

    The formula I have used is

    =IF(TEXT(A1, "hh:mm")>"18:00",0,TEXT((DATE(YEAR(A1),MONTH(A1),DAY(A1))+"18:00")-A1,"hh:mm"))

    Cell A2 : 2/14/2014 5:05:00 PM

    For the second time i calculate the time taken from 9:30 in the morning which is

    =IF(DATE(DAY(B1),MONTH(A1),YEAR(A1))=DATE(DAY(H10),MONTH(H10),YEAR(H10)),0,TEXT(B1-(DATE(YEAR(B1),MONTH(B1),DAY(B1))+"9:30"),"hh:mm"))


    I face a problem when i try to sum the differences i.e the sum of the differences

    Can anyone help in adding the results of these formulas

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: To automate Calculation of time taken

    Suggest you post up a copy of your worksheet as you have cells listed in the second formula for which you have not provided values. Difficult to analyze what the patient is suffering from if you cannot see him.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: To automate Calculation of time taken

    The formula I have used is

    =IF(TEXT(A1, "hh:mm")>"18:00",0,TEXT((DATE(YEAR(A1),MONTH(A1),DAY(A1))+"18:00")-A1,"hh:mm"))
    When working with dates and times, don't convert back and forth to text. Here is a simpler formula that will give you the same result, and the result will be in time format instead of text.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For the second time i calculate the time taken from 9:30 in the morning which is

    =IF(DATE(DAY(B1),MONTH(A1),YEAR(A1))=DATE(DAY(H10),MONTH(H10),YEAR(H10)),0,TEXT(B1-(DATE(YEAR(B1),MONTH(B1),DAY(B1))+"9:30"),"hh:mm"))
    What is in B1? H10? If you are trying to calculate the time from 9:30 AM to 5:05:00 PM (and return 0 if it is earlier than 9:30), the similarly you can use

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then you can easily add these two results to get a valid time.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: To automate Calculation of time taken

    I am able to get the required result now...If the start date is 10/12/2014 and end date is 10/15/2014 I calculate the time taken on start day and end day using formula mentioned above. In between i need to take the 2 days i.e 8 and a half hours multiplied by 2 days and add it with 5 hours 55 mins and 7 hours 35 mins

+ 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. HELP: macro to automate a calculation
    By sampsulo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2013, 09:05 AM
  2. Excel 2007 : How to automate calculation of threshold value?
    By sandyjune1988 in forum Excel General
    Replies: 1
    Last Post: 12-28-2011, 02:50 AM
  3. Automate Calculation with help of VBA
    By Dongfang in forum Excel General
    Replies: 2
    Last Post: 03-11-2011, 04:29 AM
  4. Automate simple calculation/formula
    By Leslie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-28-2005, 06:05 PM
  5. [SOLVED] Help required to automate calculation
    By Tom in forum Excel General
    Replies: 1
    Last Post: 02-02-2005, 10:06 AM

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