View Single Post
  #27   Report Post  
Posted to microsoft.public.excel.programming
Nils Titley Nils Titley is offline
external usenet poster
 
Posts: 84
Default Convert the date to day of the week.

In C you change the type to another type - my be my memory is wrong but I
believe the term is called casting


"Ron Rosenfeld" wrote:

On Sun, 23 Mar 2008 07:52:00 -0700, Nils Titley
wrote:

Ron,

I am not sure this is helping....

I changed what you have because I don't have #2/12/2008# I have "02/12/2008".


If you did that, in the CONST line, you would have gotten a "type mismatch"
error. So I don't understand what you mean here or what you did.


When I do that I get debug print
A) 02/12/2008 = 39490 120208 (ddmmyy)
B) 12/02/2008 = 39784 021208 (ddmmyy)

A) ActiveCell.Offset(0, 17).Value = Format(CLng(dt), "ddmmyy")
B) ActiveCell.Offset(0, 18).Value = Format(CLng(dt2), "ddmmyy")
Results
A) 120208
B) 21208

I tried, what I call casting, RunDate(MyNum) as
CLng(RunDate(MyNum))


I'm not familiar with your term "casting" in this context. So again, I don't
understand what you mean.


ActiveCell.Offset(0, 0).Value = Format(CLng(RunDate(MyNum)), "ddmmyy")
Data = 12/02/2008
Result = 21208
Expecte as above 120208

Please, I don't get it and don't know what to do.

Thanks


Let me repeat: "Excel stores dates as serial numbers"

If you have a value, expressed as a serial number, of 21208 (or 021208), and
then try to express that as a date, it will translate to be 21,208 days after 1
Jan 1900, or Thursday, January 23, 1958.

You still haven't indicated what your RunDate function is doing, or what MyNum
is.

Also, perhaps you do not understand the formatting a cell as a date has
AABSOLUTELY NOTHING TO DO with how Excel interprets the value in that cell. It
only determines how the value in that cell is displayed.

Excel interprets date input according to the settings/format in the REGIONAL
AND LANGUAGE settings (in Control Panel). Usually, that format defines the
order (dmy, mdy, etc) as well as the separator (usually a "/").

If your data input does not conform to these specifications (i.e. if your data
is 120208 instead of 12/02/08), you will need to manipulate the data in order
to correct this.

If you could answer the questions I've posed, it should be possible to help.
--ron