Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default same time range on different days

If I have data sets as below (up to 1000 on daily basis), how can I set a
formula that returns:
"breakfast" if the time is between 7:00 and 8:30
"lunch" if the time is between 11:30 and 14:00
"dinner" if the time is between 17:00 and 20:00
and
"midnight" if the time is between 23:00 and 1:00

the date is not important and should not be regarded, what is important is
the time period.


12/1/08 9:53
12/2/08 9:28
12/2/08 14:49
12/2/08 20:29
12/4/08 9:30
12/4/08 13:21
12/4/08 13:21
12/4/08 13:21
12/5/08 9:13


Thank you very much.
:-)
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default same time range on different days

try:

=IF(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))TIME( 7,30,),TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))<TIME(8,30,)),"breakfas t",IF(AND(TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))TIME(11,30,),TIME(HOUR (A1),MINUTE
(A1),SECOND(A1))<TIME(14,0,)),"dinner",IF(AND(TIME (HOUR(A1),MINUTE
(A1),SECOND(A1))TIME(17,0,),TIME(HOUR(A1),MINUTE( A1),SECOND(A1))<TIME
(20,0,)),"dinner",IF(OR(TIME(HOUR(A1),MINUTE(A1),S ECOND(A1))TIME
(23,0,),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<TIME
(1,0,)),"midnight",""))))

On 29 Gru, 09:36, tmax wrote:
If I have data sets as below (up to 1000 on daily basis), how can I set a
formula that returns:
"breakfast" if the time is between 7:00 and 8:30
"lunch" if the time is between 11:30 and 14:00
"dinner" if the time is between 17:00 and 20:00
and
"midnight" if the time is between 23:00 and 1:00

the date is not important and should not be regarded, what is important is
the time period.

12/1/08 9:53
12/2/08 9:28
12/2/08 14:49
12/2/08 20:29
12/4/08 9:30
12/4/08 13:21
12/4/08 13:21
12/4/08 13:21
12/5/08 9:13

Thank you very much.
:-)


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default same time range on different days

Perhaps you could clarify something for us, please, Jarek?

Why TIME(HOUR(A1),MINUTE(A1),SECOND(A1)) instead of just MOD(A1,1) ?
--
David Biddulph

"Jarek Kujawa" wrote in message
...
try:

=IF(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))TIME( 7,30,),TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))<TIME(8,30,)),"breakfas t",IF(AND(TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))TIME(11,30,),TIME(HOUR (A1),MINUTE
(A1),SECOND(A1))<TIME(14,0,)),"dinner",IF(AND(TIME (HOUR(A1),MINUTE
(A1),SECOND(A1))TIME(17,0,),TIME(HOUR(A1),MINUTE( A1),SECOND(A1))<TIME
(20,0,)),"dinner",IF(OR(TIME(HOUR(A1),MINUTE(A1),S ECOND(A1))TIME
(23,0,),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<TIME
(1,0,)),"midnight",""))))

On 29 Gru, 09:36, tmax wrote:
If I have data sets as below (up to 1000 on daily basis), how can I set a
formula that returns:
"breakfast" if the time is between 7:00 and 8:30
"lunch" if the time is between 11:30 and 14:00
"dinner" if the time is between 17:00 and 20:00
and
"midnight" if the time is between 23:00 and 1:00

the date is not important and should not be regarded, what is important
is
the time period.

12/1/08 9:53
12/2/08 9:28
12/2/08 14:49
12/2/08 20:29
12/4/08 9:30
12/4/08 13:21
12/4/08 13:21
12/4/08 13:21
12/5/08 9:13

Thank you very much.
:-)




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default same time range on different days

wow, Dave, you're following my posts, again
thanks for expressing yr doubts
nothing to add, doesn't my formula work on your PC?
;-)
HIH
pls click "YES" if my post was helpful
;-)

On 29 Gru, 11:40, "David Biddulph" <groups [at] biddulph.org.uk
wrote:
Perhaps you could clarify something for us, please, Jarek?

Why TIME(HOUR(A1),MINUTE(A1),SECOND(A1)) instead of just MOD(A1,1) ?
--
David Biddulph

"Jarek Kujawa" wrote in message

...



try:


=IF(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))TIME( 7,30,),TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))<TIME(8,30,)),"breakfas t",IF(AND(TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))TIME(11,30,),TIME(HOUR (A1),MINUTE
(A1),SECOND(A1))<TIME(14,0,)),"dinner",IF(AND(TIME (HOUR(A1),MINUTE
(A1),SECOND(A1))TIME(17,0,),TIME(HOUR(A1),MINUTE( A1),SECOND(A1))<TIME
(20,0,)),"dinner",IF(OR(TIME(HOUR(A1),MINUTE(A1),S ECOND(A1))TIME
(23,0,),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<TIME
(1,0,)),"midnight",""))))


On 29 Gru, 09:36, tmax wrote:
If I have data sets as below (up to 1000 on daily basis), how can I set a
formula that returns:
"breakfast" if the time is between 7:00 and 8:30
"lunch" if the time is between 11:30 and 14:00
"dinner" if the time is between 17:00 and 20:00
and
"midnight" if the time is between 23:00 and 1:00


the date is not important and should not be regarded, what is important
is
the time period.


12/1/08 9:53
12/2/08 9:28
12/2/08 14:49
12/2/08 20:29
12/4/08 9:30
12/4/08 13:21
12/4/08 13:21
12/4/08 13:21
12/5/08 9:13


Thank you very much.
:-)- Ukryj cytowany tekst -


- Pokaż cytowany tekst -


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default same time range on different days

MOD(A1,1)?
what an excellent formula it is...
;-)

On 29 Gru, 11:40, "David Biddulph" <groups [at] biddulph.org.uk
wrote:
Perhaps you could clarify something for us, please, Jarek?

Why TIME(HOUR(A1),MINUTE(A1),SECOND(A1)) instead of just MOD(A1,1) ?
--
David Biddulph

"Jarek Kujawa" wrote in message

...



try:


=IF(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))TIME( 7,30,),TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))<TIME(8,30,)),"breakfas t",IF(AND(TIME(HOUR
(A1),MINUTE(A1),SECOND(A1))TIME(11,30,),TIME(HOUR (A1),MINUTE
(A1),SECOND(A1))<TIME(14,0,)),"dinner",IF(AND(TIME (HOUR(A1),MINUTE
(A1),SECOND(A1))TIME(17,0,),TIME(HOUR(A1),MINUTE( A1),SECOND(A1))<TIME
(20,0,)),"dinner",IF(OR(TIME(HOUR(A1),MINUTE(A1),S ECOND(A1))TIME
(23,0,),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<TIME
(1,0,)),"midnight",""))))


On 29 Gru, 09:36, tmax wrote:
If I have data sets as below (up to 1000 on daily basis), how can I set a
formula that returns:
"breakfast" if the time is between 7:00 and 8:30
"lunch" if the time is between 11:30 and 14:00
"dinner" if the time is between 17:00 and 20:00
and
"midnight" if the time is between 23:00 and 1:00


the date is not important and should not be regarded, what is important
is
the time period.


12/1/08 9:53
12/2/08 9:28
12/2/08 14:49
12/2/08 20:29
12/4/08 9:30
12/4/08 13:21
12/4/08 13:21
12/4/08 13:21
12/5/08 9:13


Thank you very much.
:-)- Ukryj cytowany tekst -


- Pokaż cytowany tekst -




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 57
Default same time range on different days

Assuming that any time outside those periods should give a blank try

=IF(A1="","",LOOKUP(MOD(A1,1)*24,{0,1,7,8.5,11.5,1 4,17,20,23},
{"midnight","","breakfast","","lunch","","dinner", "","midnight"}))
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default same time range on different days


Thank you guys very much. Both functions work wonderfully.

I just learned quite a bit about excel :-)

Happy new year!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting days in a range Roy Excel Discussion (Misc queries) 1 April 27th 07 08:14 PM
Time between days RamOst Excel Worksheet Functions 7 May 11th 06 03:28 PM
Average of days within a range [email protected] Excel Worksheet Functions 1 January 20th 06 02:00 PM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM
Elapsed time in days Steve M via OfficeKB.com Excel Worksheet Functions 5 August 8th 05 06:21 PM


All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"