Date in Formula

Jan Wachowski

New Member
Joined
Sep 16, 2002
Messages
5
Problem is

C11 = 31/10/2002
C12 = 212
C14 = C11+C12 (RESULT IS 31/05/2002)
C16 = IF(C4="31/05/2002","31/05/2002",1)

THE RESULT I GET FOR C16 IS 1, WHEN I EXPECT IT TO BE 31/05/2002.

WHAT IS WRONG WITH MY FORMULA?

THANKS JAN
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
L

Legacy 98055

Guest
I think change the C4 in your last formula to C14. Assuming that was not just a typo in your post.

Tom
 

Larry_S

New Member
Joined
Sep 25, 2002
Messages
10
Dates are stored as numbers in Excel, and the comparison is comparing the floating point number to the text string in your comparison.

Look up the DateValue function, which converts a character string date into a floating point number that can be used as a date in formulas and compared to dates stored in cells.
 

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
Firstly I am presuming that the first date is actually 31/10/01 and you are sinmply adding 212 days to whatever that date is - ie. 31/10/01 plus 212 = 31/05/02

C14 is a date value and thus not text. In your formula for C16 you are trying to argue that C14 is text, it isn't. You could change your formula in one of 2 ways:

1. If(text(c14,"DD/MM/YY")="31/05/02","31/05/02",1)

2. If(c14=37407,"31/05/02",1)
where 37407 represents the date value of 31/05/02.

I would argue that 1 is easier.
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
The best way to do what you need is place the Date your look for in a different cell,
as it's not good practice to Hard Code your variables,
you may need to change them later:

use:

=IF(C14=B16,B16,1)

Where B16 contains the date you want.
 

Forum statistics

Threads
1,144,291
Messages
5,723,530
Members
422,502
Latest member
barakgahtan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top