+ Reply to Thread
Results 1 to 11 of 11

how to calculate half day in excel formula

Hybrid View

  1. #1
    Registered User
    Join Date
    07-08-2012
    Location
    chennai
    MS-Off Ver
    Excel 2019
    Posts
    54

    how to calculate half day in excel formula

    Hi,
    I have a data with three columns
    1) Start date
    2) End Date
    3) No of Days

    I want to calculate the date between end date and start date using the excel formula.

    My concern is if the start date and end date is half date ie 01-01-2023 12:00:00 PM then the no of days to come as 0.5 but it is coming as 1.5 day.

    Need excel formula for calculating half day

    Thanks
    Webmax
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: how to calculate half day in excel formula

    From Date To date No of Days Subtraction
    01/01/2023 00:00
    03/01/2023 00:00
    3
    2
    01/01/2023 00:00
    01/01/2023 12:00
    1.5
    0.5


    with Power Query
    // Table1
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        DT = Table.TransformColumnTypes(Source,{{"From Date", type datetime}, {"To date", type datetime}}),
        Subtract = Table.AddColumn(DT, "Subtraction", each [To date] - [From Date], type duration),
        Dec = Table.TransformColumnTypes(Subtract,{{"Subtraction", type number}})
    in
        Dec
    with formula maybe try subtract time not days

    or
    to date - from date -1
    Last edited by sandy666; 01-04-2023 at 02:03 PM.

  3. #3
    Registered User
    Join Date
    07-08-2012
    Location
    chennai
    MS-Off Ver
    Excel 2019
    Posts
    54

    Re: how to calculate half day in excel formula

    Thanks for sharing. But my requirement is in the first sample if the start date is 1/1/2023 and end date is 3/1/2023 then it should come as 3 days.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,435

    Re: how to calculate half day in excel formula

    Try

    Formula: copy to clipboard
    =B2-A2+IF(INT(B2)=INT(A2),0,1)
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    07-08-2012
    Location
    chennai
    MS-Off Ver
    Excel 2019
    Posts
    54

    Re: how to calculate half day in excel formula

    If from date and to date is same date then the no of days should come as 1 but it is come as zero
    Last edited by webmax; 01-04-2023 at 02:22 PM.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,435

    Re: how to calculate half day in excel formula

    Try

    =(INT(B2)-INT(A2))+MOD(B2,1)+1

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: how to calculate half day in excel formula

    end date is not over yet so it can't be treated as full ended day that is why I said try subtract time not days
    Last edited by sandy666; 01-04-2023 at 02:11 PM.

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: how to calculate half day in excel formula

    subtraction of the same dates = 0 not 1
    1-1 = 1 or 0 ? basic math

  9. #9
    Registered User
    Join Date
    07-08-2012
    Location
    chennai
    MS-Off Ver
    Excel 2019
    Posts
    54

    Re: how to calculate half day in excel formula

    still i am getting wrong dates using the above formula.

    Attaching the excel sheet with different scenarios. i have also added the output required.

    Thanks
    Webmax
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,435

    Re: how to calculate half day in excel formula

    See attached
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,435

    Re: how to calculate half day in excel formula

    Try

    =(INT(B6)-INT(A6))-MOD(B6,1)-MOD(A6,1)+1

    allows for midday START

+ 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. calculate working hours excluding half day leaves
    By marlon.baruc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-09-2021, 07:02 AM
  2. calculate a half-life string based on given data
    By Scott449 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-18-2019, 03:03 AM
  3. [SOLVED] formula to calculate totals using whole & half numbers
    By Sasche in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-25-2018, 03:15 PM
  4. VBA to calculate half day/ full day as per time sheet
    By Avinashch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-13-2016, 12:54 PM
  5. Formula to calculate half wins and half losses
    By chilli76 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-27-2014, 07:33 AM
  6. [SOLVED] Formula to calculate if employee is working on each half hour
    By holowugz in forum Excel General
    Replies: 10
    Last Post: 07-16-2012, 08:29 PM
  7. Calculate time difference to the half hour
    By Ken Ivins in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 03:05 PM

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