View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Changing the date in a cell

As you said, dates are funny things

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Dave Peterson" wrote in message
...
Even VBA has a couple of different ways to get the value(?) of a date:

with activecell
.numberformat = "General" 'just not Text
.value = date
msgbox .value & vblf & .value2
end with




Sandy Mann wrote:

Stan Brown" wrote in message
t...
Indeed, that works, but why? I thought all dates and times were
stored internally as real numbers.


I thought that as well. I have written many times in these NG's that
dates
are just numbers formatted to look like numbers and so far no one has
ever
corrected me but I am now having doubts if it is that simple.

I am sure that it was Dave Peterson who once said in answering one of my
posts *Dates are funny*

Certainly they seem to be treated differently by XL to all other entries.
If I enter 39452 in a cell and format it as Accounting I see £39,452.00
in
the cell but still simply 39452 in the formula bar. If I format the cell
as
a date I see 5 Jan 2008 in the cell and 05/01/2008 in the formula bar.
So I
am not simply seeing in the formula bar the number formatted to look like
a
date by the formatting I applied or the number that I enter. It is
almost
as if XL has changed the number into a string - well a funny sort of
string
anyway - and applied the formatting to that. If this is what is really
being stored in the cell then it explains why the replacement works but
XL
must then re-interpret the *string* back into a number whenever a formula
uses it.

As Dave said, "Dates are funny"

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk

"Stan Brown" wrote in message
t...
Fri, 4 Jan 2008 16:41:32 -0000 from Bob Phillips
:
Just do a global replace on 2007 for 2008.

Indeed, that works, but why? I thought all dates and times were
stored internally as real numbers.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"If there's one thing I know, it's men. I ought to: it's
been my life work." -- Marie Dressler, in /Dinner at Eight/


--

Dave Peterson