Excel TIme Formula - calculate from specific Range

%3CLINGO-SUB%20id%3D%22lingo-sub-2055439%22%20slang%3D%22en-US%22%3EExcel%20TIme%20Formula%20-%20calculate%20from%20specific%20Range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2055439%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20having%20trouble%20wrapping%20my%20head%20around%20this%3A%20Id%20like%20to%20calculate%20and%20display%20the%20hours%20between%20midnight%20and%207am%20in%20a%20third%20cell%20from%20a%20range%20entered%20into%202%20different%20Cells.%20E.g.%20C3%3D21%3A00%3B%20D3%3D%2003%3A00%2C%20id%20like%20the%203rd%20Cell%20e.g.%20E3%3D%203hrs%20(midnight%20to%203am).%20This%20needs%20to%20be%20dynamic%20and%20understand%20that%20the%20constraints%20are%20midnight%20to%207am%20and%20to%20only%20calculate%20the%20hours%20as%20such.%20Time%20range%20(in%20C3%2FD3)%20may%20be%20any%20time%20in%20a%2024hr%20period.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20makes%20sense%2C%20hope%20someone%20can%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20much%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EChris%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2055439%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2056069%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20TIme%20Formula%20-%20calculate%20from%20specific%20Range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2056069%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F927088%22%20target%3D%22_blank%22%3E%40StardrifterIV%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20could%20be%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20376px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F246056i6BF2AC13B19A63A0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ewe%20assume%20if%20value%20in%20D%20is%20more%20than%20value%20in%20C%20that's%20the%20same%20day.%20Otherwise%20how%20Excel%20knows%20D4%20is%20the%20same%20day%20as%20C4%20or%20next%20one%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2059001%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20TIme%20Formula%20-%20calculate%20from%20specific%20Range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2059001%22%20slang%3D%22en-US%22%3E%3CP%3EHI%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%20%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20very%20much%20appreciate%20you%20having%20a%20look%20at%20this.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E...%20here%26nbsp%3B%20in%20lies%20the%20rub%2C%20I%20need%20to%20isolate%20only%20the%20hours%20from%20Midnight%20to%203%20am%20from%20the%209pm%20-%203am%20data%20range.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20going%20down%20the%20path%20of%20(If)%20as%20it%20is%20the%20only%20way%20I%20see%20to%20ask%20excel%20to%20look%20specifically%20for%20times%20between%20midnight%20and%207am%2C%20however%20my%20knowledge%20of%20excel%20is%20not%20poor%2C%20it%20is%20certainly%20a%20struggle%20to%20get%20through%20this%20one%20with%20the%20conceptualisation%20and%20the%20syntax%20as%20well%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20thinking%20'If%20D%20%3D%2000%3A00%20thru%2007%3A00%20then%20sum(00%3A00%3A00%20%2B%20D3)'%20something%20to%20that%20effect%20would%20result%20in%20the%203hours%20that%20I%20am%20looking%20for%20in%20the%20example.%20I%20dont%20know%20the%20excel%20Syntax%20and%20functions%20well%20enough%2C%20and%20have%20spent%20hours%20trolling%20through%20the%20various%20Excel%20functions%20to%20find%20the%20concept%2C%20without%20even%20knowing%20if%20im%20barking%20up%20the%20right%20tree%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again%20for%20your%20response.%20Any%20Guidance%20is%20most%20appreciated!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ET%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

 

Hi all,

 

I am having trouble wrapping my head around this: Id like to calculate and display the hours between midnight and 7am in a third cell from a range entered into 2 different Cells. E.g. C3=21:00; D3= 03:00, id like the 3rd Cell e.g. E3= 3hrs (midnight to 3am). This needs to be dynamic and understand that the constraints are midnight to 7am and to only calculate the hours as such. Time range (in C3/D3) may be any time in a 24hr period.

 

Hope this makes sense, hope someone can help.

 

Thanks so much

 

Chris

 

3 Replies

@StardrifterIV 

That could be

image.png

we assume if value in D is more than value in C that's the same day. Otherwise how Excel knows D4 is the same day as C4 or next one?

HI@Sergei Baklan ,

 

I very much appreciate you having a look at this. 

 

... here  in lies the rub, I need to isolate only the hours from Midnight to 3 am from the 9pm - 3am data range. 

 

I am going down the path of (If) as it is the only way I see to ask excel to look specifically for times between midnight and 7am, however my knowledge of excel is not poor, it is certainly a struggle to get through this one with the conceptualisation and the syntax as well

 

I am thinking 'If D = 00:00 thru 07:00 then sum(00:00:00 + D3)' something to that effect would result in the 3hours that I am looking for in the example. I dont know the excel Syntax and functions well enough, and have spent hours trolling through the various Excel functions to find the concept, without even knowing if im barking up the right tree

 

Thanks again for your response. Any Guidance is most appreciated!

 

T

@StardrifterIV 

Syntax for  'If D = 00:00 thru 07:00 then sum(00:00:00 + D3)' will be

=IF( D3<=7/24,D3, MOD(D3-C3,1) )

 assuming we use previous formula for another time. Entire logic is not clear for me, what it shall be if D3 is 07:01 and C3 is 23:59, etc.

To explain the formula, days in Excel are integers where 1 is Jan 01, 1900. Time is decimal part of the number. Thus in calculations one day is equal to 1 and one hour to 1/24.

Thus 2021-01-14 13:00 is human friendly representation of datetime, actually that is 44210+13/24 or 44210.54167