ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using dates in IF statements (https://www.excelbanter.com/excel-discussion-misc-queries/150295-using-dates-if-statements.html)

altah

Using dates in IF statements
 
I need to create a statement with the following criteria and response.

Please help.

Thanks,

If 7/15/07 1/2/02 + 5 years, then 5, otherwise 3.33

Bob Phillips

Using dates in IF statements
 
Don't get it, Today's date will ALWAYS be greater than 2nd Jan 2007, because
that date has already passed.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"altah" wrote in message
...
I need to create a statement with the following criteria and response.

Please help.

Thanks,

If 7/15/07 1/2/02 + 5 years, then 5, otherwise 3.33




joeu2004

Using dates in IF statements
 
On Jul 15, 2:08 pm, altah wrote:
I need to create a statement with the following criteria and response.
Please help.
[....]
If 7/15/07 1/2/02 + 5 years, then 5, otherwise 3.33


Does this do what you want?

=if(today() date(5+year(A1), month(A1), day(A1)), 5, 3.33)

where today() and A1 replace what you wrote as 7/15/07 and 1/2/02
respectively.

Note the difference between that and the following:

=if(datedif(A1, today(), "y") 5, 5, 3.33)

You decide which meets your intentions better.


altah

Using dates in IF statements
 
Works perfectly
Thanks much


"joeu2004" wrote:

On Jul 15, 2:08 pm, altah wrote:
I need to create a statement with the following criteria and response.
Please help.
[....]
If 7/15/07 1/2/02 + 5 years, then 5, otherwise 3.33


Does this do what you want?

=if(today() date(5+year(A1), month(A1), day(A1)), 5, 3.33)

where today() and A1 replace what you wrote as 7/15/07 and 1/2/02
respectively.

Note the difference between that and the following:

=if(datedif(A1, today(), "y") 5, 5, 3.33)

You decide which meets your intentions better.




All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com