On Sun, 21 Feb 2010 11:03:22 -0800 (PST), Chet <(E-Mail Removed)> wrote:
>Am trying to understand why is that when I have a variable MaxDate
>(undeclared) and is has a value of 38697 and if I use
>=TEXT(MaxDate,"mm/dd/yy") I get the correct value of 12/12/09 but if I
>use function =CDATE(MaxDate) I get 12/11/2005 as an output? Also the
>format command didn't work either to convert MaxDate with the code
>=format(MaxDate, "mm/dd/yy") as it also gave 12/11/2005 when the
>correct output was 12/12/09. I am trying to understand this.
>
>Thanks,
>Chet
It occurs because in your Excel options, you have selected to use the 1904 date
system. When you use the TEXT command, it being a Worksheet Function, it uses
whichever date system you have set into your Excel Options. In the 1904 date
system, "0" = 1/1/1904
However, CDATE, being a native VBA method, converts dates according to the
method in VBA, in which "Dates are stored as part of a real number. Values to
the left of the decimal represent the date; values to the right of the decimal
represent the time. Negative numbers represent dates prior to December 30,
1899."
--ron
|