Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Tricky IF/Then Date based formula needed

First, Look at the AND function. Then,the OR function and then the IF
function. Put together in that order.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Titanium" wrote in message
...
Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat
from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tricky IF/Then Date based formula needed

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 510
Default Tricky IF/Then Date based formula needed

Hi

Add an additional sheet (p.e. Times - you can hide it later)
On sheet times, create a table
1 16:00
2 20:00
7 17:00

(In column A day numbers for Sunday, Monday and Saturday, in column B
according closure times)

Now your formula for B2 will be
=IF(AND(MOD(A2;1)=(7/24),MOD(A2,1)<=CHOOSE(MATCH(WEEKDAY(A2),Times!$A$1 :$A$3,1),16/24,20/204,17/24)),"On
Time","Closure Time")
etc.


Arvi Laanemets


"Titanium" wrote in message
...
Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat
from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Tricky IF/Then Date based formula needed

one way
with date on A2 formatted as "ddd, mm/d/yy, h:mm"

=IF(AND(HOUR(A2)=7,ROUNDDOWN((A2-INT(A2)),8)<=(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{ 16,20,20,20,20,20,15}))/24),"On Time","Closure Time")

the 20:00 is tricky! <g

"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Thanks so much for your reply!

"Don Guillett" wrote:

First, Look at the AND function. Then,the OR function and then the IF
function. Put together in that order.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Titanium" wrote in message
...
Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat
from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Thanks so much for your reply! I'll try your method and get back to you. So
many replies and so many different ideas. All appreciated.

"fair_thumb" wrote:

one way
with date on A2 formatted as "ddd, mm/d/yy, h:mm"

=IF(AND(HOUR(A2)=7,ROUNDDOWN((A2-INT(A2)),8)<=(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{ 16,20,20,20,20,20,15}))/24),"On Time","Closure Time")

the 20:00 is tricky! <g

"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Thanks so much for your reply! That is an interesting approach. I will try it
and get back to you. I can't believe so many replied.

"Arvi Laanemets" wrote:

Hi

Add an additional sheet (p.e. Times - you can hide it later)
On sheet times, create a table
1 16:00
2 20:00
7 17:00

(In column A day numbers for Sunday, Monday and Saturday, in column B
according closure times)

Now your formula for B2 will be
=IF(AND(MOD(A2;1)=(7/24),MOD(A2,1)<=CHOOSE(MATCH(WEEKDAY(A2),Times!$A$1 :$A$3,1),16/24,20/204,17/24)),"On
Time","Closure Time")
etc.


Arvi Laanemets


"Titanium" wrote in message
...
Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat
from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.




  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tricky IF/Then Date based formula needed

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

I hate to ask this, but would you mind explaining the formula to me in words.
I'm a little lost as to how the AND, ROUNDOWN,INT & LOOKUP operate. Also,
what is the purpose/functionality of the curly brackets? I have looked them
all up in Excel Help, but I'm not quite making sense of them. I've decided to
go with this formula as it does suite me best, so I'd really like to get a
handle on what all I'm typing so the next time I have a similar problem to
solve I won't have t look for help. Thanks in advance for all your help.

"fair_thumb" wrote:

one way
with date on A2 formatted as "ddd, mm/d/yy, h:mm"

=IF(AND(HOUR(A2)=7,ROUNDDOWN((A2-INT(A2)),8)<=(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{ 16,20,20,20,20,20,15}))/24),"On Time","Closure Time")

the 20:00 is tricky! <g

"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Thanks for the update. I'll try your formula out again.

"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Tricky IF/Then Date based formula needed

the formula can be verified.
try using toolsformula auditingevaluate formula..

=if(and(condition_1,condition_2),"On Time","Closure Time")

For the "And(true,true)"

condition_1 :
"HOUR(A2)=7" : the Hour should be equal or past 7:00
AM.(e.g.7AM,7:30AM,11:30AM,6PM...)

condition_2 :
"ROUNDDOWN((A2-INT(A2)),8)
<=
(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{16,20,20,20,2 0,20,15}))/24"

when A2 is Monday with time at 20:00:01 or 8:00:01PM:
-------------Hour(A2)<=20 : the answer will be true, disregarding the
00:00:01 which was delimited by the Hour() function...as an hour integer
so, to provide more sensitivity on the formula, suggested was to use
"ROUNDDOWN((A2-INT(A2)),8) instead of Hour(A2)
for A2 with 20:00:01 or 8:00:01PM
ROUNDDOWN((A2-INT(A2)),8) = 0.8333449
this is 0.8333449 of 1 day
With this condition_2, the answer must be "False"
but using "=HOUR(A2)<=20" : the condition will be "True", which must not be.

For the Lookup
(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{16,20,20,20,2 0,20,15}))/24" : the curly
brackets contains the constants (numbers in this case).
{1,2,3,4,5,6,7} : Excel strores the weekdays numbered as 1 to 7, which
corresponds to Sunday thru Saturday.
{16,20,20,20,20,20,15} : the end hour for each day (sunday-saturday) that
limits the "On Time" criteria.
When Lookup found a match on Weekday(A2) = {1 or 2 or 3 or 4 or 5 or 6 or 7},
it will pull-out one value from {16,20,20,20,20,20,15}.
Meaning
if Weekday(a2) =1, Lookup result = 16
if Weekday(a2) =2, Lookup result = 20
if Weekday(a2) =7, Lookup result = 15

the lookup result will then be divided to 24, and convert the lookup result
into a portion of a day..

Try to segregate each functional formula and later merge them into one
formula, so you can verify and learn from it.

Regards and thanks for the feedback.

"Titanium" wrote:

I hate to ask this, but would you mind explaining the formula to me in words.
I'm a little lost as to how the AND, ROUNDOWN,INT & LOOKUP operate. Also,
what is the purpose/functionality of the curly brackets? I have looked them
all up in Excel Help, but I'm not quite making sense of them. I've decided to
go with this formula as it does suite me best, so I'd really like to get a
handle on what all I'm typing so the next time I have a similar problem to
solve I won't have t look for help. Thanks in advance for all your help.

"fair_thumb" wrote:

one way
with date on A2 formatted as "ddd, mm/d/yy, h:mm"

=IF(AND(HOUR(A2)=7,ROUNDDOWN((A2-INT(A2)),8)<=(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{ 16,20,20,20,20,20,15}))/24),"On Time","Closure Time")

the 20:00 is tricky! <g

"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tricky IF/Then Date based formula needed

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Thanks so much for the explaination. That's great!

"JMB" wrote:

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #17   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

I wasn't aware of that feature. Thanks so much for all your help!

"fair_thumb" wrote:

the formula can be verified.
try using toolsformula auditingevaluate formula..

=if(and(condition_1,condition_2),"On Time","Closure Time")

For the "And(true,true)"

condition_1 :
"HOUR(A2)=7" : the Hour should be equal or past 7:00
AM.(e.g.7AM,7:30AM,11:30AM,6PM...)

condition_2 :
"ROUNDDOWN((A2-INT(A2)),8)
<=
(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{16,20,20,20,2 0,20,15}))/24"

when A2 is Monday with time at 20:00:01 or 8:00:01PM:
-------------Hour(A2)<=20 : the answer will be true, disregarding the
00:00:01 which was delimited by the Hour() function...as an hour integer
so, to provide more sensitivity on the formula, suggested was to use
"ROUNDDOWN((A2-INT(A2)),8) instead of Hour(A2)
for A2 with 20:00:01 or 8:00:01PM
ROUNDDOWN((A2-INT(A2)),8) = 0.8333449
this is 0.8333449 of 1 day
With this condition_2, the answer must be "False"
but using "=HOUR(A2)<=20" : the condition will be "True", which must not be.

For the Lookup
(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{16,20,20,20,2 0,20,15}))/24" : the curly
brackets contains the constants (numbers in this case).
{1,2,3,4,5,6,7} : Excel strores the weekdays numbered as 1 to 7, which
corresponds to Sunday thru Saturday.
{16,20,20,20,20,20,15} : the end hour for each day (sunday-saturday) that
limits the "On Time" criteria.
When Lookup found a match on Weekday(A2) = {1 or 2 or 3 or 4 or 5 or 6 or 7},
it will pull-out one value from {16,20,20,20,20,20,15}.
Meaning
if Weekday(a2) =1, Lookup result = 16
if Weekday(a2) =2, Lookup result = 20
if Weekday(a2) =7, Lookup result = 15

the lookup result will then be divided to 24, and convert the lookup result
into a portion of a day..

Try to segregate each functional formula and later merge them into one
formula, so you can verify and learn from it.

Regards and thanks for the feedback.

"Titanium" wrote:

I hate to ask this, but would you mind explaining the formula to me in words.
I'm a little lost as to how the AND, ROUNDOWN,INT & LOOKUP operate. Also,
what is the purpose/functionality of the curly brackets? I have looked them
all up in Excel Help, but I'm not quite making sense of them. I've decided to
go with this formula as it does suite me best, so I'd really like to get a
handle on what all I'm typing so the next time I have a similar problem to
solve I won't have t look for help. Thanks in advance for all your help.

"fair_thumb" wrote:

one way
with date on A2 formatted as "ddd, mm/d/yy, h:mm"

=IF(AND(HOUR(A2)=7,ROUNDDOWN((A2-INT(A2)),8)<=(LOOKUP(WEEKDAY(A2),{1,2,3,4,5,6,7},{ 16,20,20,20,20,20,15}))/24),"On Time","Closure Time")

the 20:00 is tricky! <g

"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #18   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tricky IF/Then Date based formula needed

Quite welcome. Thanks for the feedback.

"Titanium" wrote:

Thanks so much for the explaination. That's great!

"JMB" wrote:

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #19   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

I hate to bother you again, but I've been trying to make a modification to
this formula, but I can't figure it out.

This is what I came up with:


=IF(AND(HOUR(A16)LOOKUP(WEEKDAY(A16,2),{0,6,7},{5 ,7,7})),HOUR(A16)<LOOKUP(WEEKDAY(A16,2),{0,6,7},{2 0,15,16})),"On Time","Closure Time")


The operation time is different from weekends to weekends. Weekdays start
time is 05:00 and weekends start at 07:00. Condition #1 is the only change I
need to make. Could you please help me with this. Again, thanks so much for
all your assistance.



========
"JMB" wrote:

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

  #20   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Tricky IF/Then Date based formula needed

I think you just added an extra ")" at the end of the first lookup. And you
probably want = for the first condition if it is "open" at exactly 5:00 or
7:00.

=IF(AND(HOUR(A16)=LOOKUP(WEEKDAY(A16,2),{0,6,7},{ 5,7,7}),HOUR(A16)<LOOKUP(WEEKDAY(A16,2),{0,6,7},{2 0,15,16})),"On Time","Closure Time")


"Titanium" wrote:

I hate to bother you again, but I've been trying to make a modification to
this formula, but I can't figure it out.

This is what I came up with:


=IF(AND(HOUR(A16)LOOKUP(WEEKDAY(A16,2),{0,6,7},{5 ,7,7})),HOUR(A16)<LOOKUP(WEEKDAY(A16,2),{0,6,7},{2 0,15,16})),"On Time","Closure Time")


The operation time is different from weekends to weekends. Weekdays start
time is 05:00 and weekends start at 07:00. Condition #1 is the only change I
need to make. Could you please help me with this. Again, thanks so much for
all your assistance.



========
"JMB" wrote:

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.



  #21   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Tricky IF/Then Date based formula needed

Superb! Thanks so much.

"JMB" wrote:

I think you just added an extra ")" at the end of the first lookup. And you
probably want = for the first condition if it is "open" at exactly 5:00 or
7:00.

=IF(AND(HOUR(A16)=LOOKUP(WEEKDAY(A16,2),{0,6,7},{ 5,7,7}),HOUR(A16)<LOOKUP(WEEKDAY(A16,2),{0,6,7},{2 0,15,16})),"On Time","Closure Time")


"Titanium" wrote:

I hate to bother you again, but I've been trying to make a modification to
this formula, but I can't figure it out.

This is what I came up with:


=IF(AND(HOUR(A16)LOOKUP(WEEKDAY(A16,2),{0,6,7},{5 ,7,7})),HOUR(A16)<LOOKUP(WEEKDAY(A16,2),{0,6,7},{2 0,15,16})),"On Time","Closure Time")


The operation time is different from weekends to weekends. Weekdays start
time is 05:00 and weekends start at 07:00. Condition #1 is the only change I
need to make. Could you please help me with this. Again, thanks so much for
all your assistance.



========
"JMB" wrote:

The weekday function returns a number (1-7) to indicate which day of the week
it is. The second parameter of the weekday function dictates which day is
considered number 1.

If the second parameter of weekday is:
1 or omitted - Returns Numbers 1 (Sunday) through 7 (Saturday).
2 - Returns Numbers 1 (Monday) through 7 (Sunday).
3 - Returns Numbers 0 (Monday) through 6 (Sunday).

Since your weekdays all have the same operating hours, it makes sense to
group them together (I used option 2, although option 3 could also work, but
{0,6,7} would have to be changed to {0,5,6}).

And, yes the 0 represents all of the weekdays. If Lookup can't find the
lookup value, it matches to the largest number that is less than or equal to
the lookup value(You could also use a 1 instead of 0 - I used 0 out of
habit). So if Weekday returns 1-5, Lookup will match to the 0 and return the
first number from the second list (20).


"Titanium" wrote:

If you don't mind can you please explain this portion of your formula:
<LOOKUP(WEEKDAY(A16,2),{0,6,7}

I don't quite understand the ,2 after the A16 - what does it signify?

Also, the 0, does it stand for all of the weekdays?

Again, thanks in advance for your assistance.


"JMB" wrote:

I noticed a small error. The 5 in {5,6,7} should have been a 0 (not sure how
that got there). Also, I notice the 19+Lookup(...) can be made shorter. My
revised suggestion would be:

=IF(AND(HOUR(A16)=7,HOUR(A16)<LOOKUP(WEEKDAY(A16, 2),{0,6,7},{20,15,16})),"On Time","Closure Time")

Sorry about that.

"Titanium" wrote:

JMB, Closed at 20:00. Thanks so much for your reply!

"JMB" wrote:

This seems to work, but if the time is exactly 20:00 (for Monday) do you want
"Open" or "Closed"??

If you want Closed, you could try:
=IF(AND(HOUR(A16)=7,HOUR(A16)<=19+LOOKUP(WEEKDAY( A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")

If you would want open for that example:
=IF(AND(HOUR(A16)=7,HOUR(A16-1/86400)<=19+LOOKUP(WEEKDAY(A16,2),{5,6,7},{0,-5,-4})),"On Time","Closure Time")



"Titanium" wrote:

Column A has the date and time displayed: Thu, 06/14/07, 11:15
Column B needs to calculate: "If (A=Mon to Fri from 7:00 to 20:00, Sat from
7:00 to 15:00, Sun from 7:00 to 16:00 Then Display in Column B "On Time")
If False then Display in Column B "Closure Time")

I don't even know where to start with this one. Any assistance would
certainly be appreciated. Thanks in advance for your help.

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
Tricky Date calculation: How to calculate a future date [email protected] Excel Discussion (Misc queries) 9 August 11th 06 04:24 AM
Date formula needed Rich Hayes Excel Worksheet Functions 4 December 9th 05 07:25 PM
Date stamp formula results? Tricky problem? mjp Excel Discussion (Misc queries) 0 November 18th 05 04:11 PM
Date formula needed VDan Excel Discussion (Misc queries) 4 August 31st 05 04:01 PM
Tricky formulas needed Myrna Larson Excel Worksheet Functions 2 October 29th 04 03:29 AM


All times are GMT +1. The time now is 02:44 AM.

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"