Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default HELP! I need to make an IF Statement comparing date/time fields..

I have been trying to use an IF statement to compare date/time entries in a
report I am building (format = yyyy-mm-dd hh:mm:ss). Essentially there are a
few comparisons I must make to return a YES or NO value. I am unable to get
the last one working.

1. Comparing one date/time (F2) to see if it is within 45 minutes of another
field (E2). I made another field to calculate the difference between E2 and
F2 (=E2-F2) and left it in the format hh:mm. I created another field (H2)
with the value of 00:45 (hh:mm). Essentially, I wanted the statement to
return a value of NO if F2 is blank, a value of YES if the time difference is
45 minutes or less, and a value of NO if the time difference was more than 45
minutes. Here is the resulting statement:
=IF(F2="", "No", IF(G2=H2, "Yes", "No"))

2. Comparing one date/time (I2) to see if it is within 15 minutes of another
field (E2). I made another field to calculate the difference between E2 and
I2 (=E2-I2) and left it in the format hh:mm. I created another field (K2)
with the value of 00:15 (hh:mm). Essentially, I wanted the statement to
return a value of NO if I2 is blank, a value of YES if the time difference is
15 minutes or less, and a value of NO if the time difference was more than 15
minutes. Here is the resulting statement:
=IF(I2="", "No", IF(J2=K2, "Yes", "No"))

3. Lastly, I need to create an IF statement that will return a value of NO
if the field I2 is blank, YES is if the date/time in I2 is less than or equal
to E2+60 mins, and NO if the date/time in I2 is greater than E2+60 mins.

example:
I2 = 2009-11-04 09:15:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 10:45:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 11:00:00, E2 = 2009-11-04 10:00:00, YES
I2 = Blank, E2 = 2009-11-04 10:00:00, NO
I2 = 2009-11-04 11:01:00, E2 = 2009-11-04 10:00:00, NO


Can someone please advise if there is a better formula to use?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default HELP! I need to make an IF Statement comparing date/time fields..

=IF(I2="","No",IF(I2<=E2+TIME(1,0,0),"Yes","No"))

If this post helps click Yes
---------------
Jacob Skaria


"Ksoloway" wrote:

I have been trying to use an IF statement to compare date/time entries in a
report I am building (format = yyyy-mm-dd hh:mm:ss). Essentially there are a
few comparisons I must make to return a YES or NO value. I am unable to get
the last one working.

1. Comparing one date/time (F2) to see if it is within 45 minutes of another
field (E2). I made another field to calculate the difference between E2 and
F2 (=E2-F2) and left it in the format hh:mm. I created another field (H2)
with the value of 00:45 (hh:mm). Essentially, I wanted the statement to
return a value of NO if F2 is blank, a value of YES if the time difference is
45 minutes or less, and a value of NO if the time difference was more than 45
minutes. Here is the resulting statement:
=IF(F2="", "No", IF(G2=H2, "Yes", "No"))

2. Comparing one date/time (I2) to see if it is within 15 minutes of another
field (E2). I made another field to calculate the difference between E2 and
I2 (=E2-I2) and left it in the format hh:mm. I created another field (K2)
with the value of 00:15 (hh:mm). Essentially, I wanted the statement to
return a value of NO if I2 is blank, a value of YES if the time difference is
15 minutes or less, and a value of NO if the time difference was more than 15
minutes. Here is the resulting statement:
=IF(I2="", "No", IF(J2=K2, "Yes", "No"))

3. Lastly, I need to create an IF statement that will return a value of NO
if the field I2 is blank, YES is if the date/time in I2 is less than or equal
to E2+60 mins, and NO if the date/time in I2 is greater than E2+60 mins.

example:
I2 = 2009-11-04 09:15:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 10:45:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 11:00:00, E2 = 2009-11-04 10:00:00, YES
I2 = Blank, E2 = 2009-11-04 10:00:00, NO
I2 = 2009-11-04 11:01:00, E2 = 2009-11-04 10:00:00, NO


Can someone please advise if there is a better formula to use?

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 135
Default HELP! I need to make an IF Statement comparing date/time fields..

This formula will work for you. If either I2 or E2 are blank, then you get
"No". Then this tests for hours differences and minutes differences. The
hour difference is allowed to be one if the minutes difference is zero. I
have used ABS (absolute value) in the date differences because it looks like
either date/time could be earlier.

=IF(I2="","No",IF(E2="","No",IF(HOUR(ABS(E2-I2))0,IF(HOUR(ABS(E2-I2))1,"No",IF(MINUTE(ABS(E2-I2))=0,"Yes","No")),IF(MINUTE(ABS(E2-I2))<=60,"Yes","No"))))

Try it out...

--
Daryl S


"Ksoloway" wrote:

I have been trying to use an IF statement to compare date/time entries in a
report I am building (format = yyyy-mm-dd hh:mm:ss). Essentially there are a
few comparisons I must make to return a YES or NO value. I am unable to get
the last one working.

1. Comparing one date/time (F2) to see if it is within 45 minutes of another
field (E2). I made another field to calculate the difference between E2 and
F2 (=E2-F2) and left it in the format hh:mm. I created another field (H2)
with the value of 00:45 (hh:mm). Essentially, I wanted the statement to
return a value of NO if F2 is blank, a value of YES if the time difference is
45 minutes or less, and a value of NO if the time difference was more than 45
minutes. Here is the resulting statement:
=IF(F2="", "No", IF(G2=H2, "Yes", "No"))

2. Comparing one date/time (I2) to see if it is within 15 minutes of another
field (E2). I made another field to calculate the difference between E2 and
I2 (=E2-I2) and left it in the format hh:mm. I created another field (K2)
with the value of 00:15 (hh:mm). Essentially, I wanted the statement to
return a value of NO if I2 is blank, a value of YES if the time difference is
15 minutes or less, and a value of NO if the time difference was more than 15
minutes. Here is the resulting statement:
=IF(I2="", "No", IF(J2=K2, "Yes", "No"))

3. Lastly, I need to create an IF statement that will return a value of NO
if the field I2 is blank, YES is if the date/time in I2 is less than or equal
to E2+60 mins, and NO if the date/time in I2 is greater than E2+60 mins.

example:
I2 = 2009-11-04 09:15:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 10:45:00, E2 = 2009-11-04 10:00:00, YES
I2 = 2009-11-04 11:00:00, E2 = 2009-11-04 10:00:00, YES
I2 = Blank, E2 = 2009-11-04 10:00:00, NO
I2 = 2009-11-04 11:01:00, E2 = 2009-11-04 10:00:00, NO


Can someone please advise if there is a better formula to use?

Thanks!

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
HELP! IF Statements Comparing Date/Time Entries (yyyy-mm-dd hh:mm Ksoloway Excel Discussion (Misc queries) 1 November 5th 09 02:56 AM
How to calculate between two date/time fields? Cam Excel Discussion (Misc queries) 1 August 29th 08 10:26 PM
Count minutes between two time/date fields safetymast Excel Discussion (Misc queries) 8 December 20th 07 04:53 PM
Adding Date/Time fields teastman New Users to Excel 6 January 1st 06 05:08 AM
Comparing Date Fields Cathy Excel Worksheet Functions 1 November 6th 04 01:29 AM


All times are GMT +1. The time now is 12:37 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"