Problem of ToOADate function

  • Thread starter Thread starter snow
  • Start date Start date
S

snow

Hi All,

ToOADate can change a date value to a double value, but if I change
the Regional and Lauguage setting in control panel, for example,
change English(US) to English(Australia) , the same date time will get
different double values from function ToOADate. How to always get the
same double value no matter what setting is in control panel?

Thanks for the help!
 
Hi Snow,

If you change English(US) to English(Australia), do you than change all your
individual dates as well?

11-1-2007 means in General English notation 11 January 2007 in USA English
it means November 1th 2007.

Cor



Cor
 
Hi Snow,

If you change English(US) to English(Australia), do you than change all your
individual dates as well?

11-1-2007 means in General English notation 11 January 2007 in USA English
it means November 1th 2007.

Cor

Cor

"snow" <[email protected]> schreef in bericht





- Show quoted text -

Hi Cor,

That is the reason caused the problem. I developed an application
program which plot the date and temperature in the spreadsheet. The
date on my computer, for example 3/4/2007, means March 4th, 2007 ,
English(US) setting. When the program runs on a customer's computer,
the same date changes to April, 3rd, 2007, English(Australia) setting.
The program reads the date from spreadsheet and changes date to double
value for plotting, the result is totally different. The date format
is defined by the computer system setting. The functin ToOADate should
know the system setting, but it seems alway taking mm/dd/yy format and
changes to double. So how to get the same double value from the date
on different time setting systems?
 
snow wrote:
I developed an application
program which plot the date and temperature in the spreadsheet. The
date on my computer, for example 3/4/2007, means March 4th, 2007 ,
English(US) setting. When the program runs on a customer's computer,
the same date changes to April, 3rd, 2007, English(Australia) setting.
The program reads the date from spreadsheet and changes date to double
value for plotting, the result is totally different. The date format
is defined by the computer system setting. The functin ToOADate should
know the system setting, but it seems alway taking mm/dd/yy format and
changes to double. So how to get the same double value from the date
on different time setting systems?

It seems to me that the problem has nothing to do with ToOADate method
-- which just operates on the binaries of the current date value --
but in the date assignment itself.

Maybe you could provide the code that reads the data from the
spreadsheet, for that's where the problem lies in, I guess.

HTH.

Regards,

Branco.
 
snow wrote:



It seems to me that the problem has nothing to do withToOADatemethod
-- which just operates on the binaries of the current date value --
but in the date assignment itself.

Maybe you could provide the code that reads the data from the
spreadsheet, for that's where the problem lies in, I guess.

HTH.

Regards,

Branco.

What my problem is the date setting. If the computer setting is
English(US), I have a date variable, for example myDate = #3/5/2007
12:00:00#, when I use myDate.ToOADate, I got a double value myDouble;
If the computer setting is English(Australia), myDate = #5/3/2007
12:00:00", which is the same date in different format, when I use
myDate.ToOADate, I got another double value myNew Double. myDouble
should be same as myNewDouble. so How to get same double value in
different time setting computer? is it a bug for function ToOADate?

Thanks!
 
snow wrote:
What my problem is the date setting.

I don't thik so. Maybe I'm wrong, but your problem seems to be the way
you parse the date provided by the Excel spreadsheet.
If the computer setting is
English(US), I have a date variable, for example myDate = #3/5/2007
12:00:00#, when I use myDate.ToOADate, I got a double value myDouble;
If the computer setting is English(Australia), myDate = #5/3/2007
12:00:00", which is the same date in different format,
<snip>

Nope. The date literal uses the format #month/day/year#, regardless of
the cmputer's international settings.

Therefore, #5/3/2007#, regardless of the international settings, will
always represent the 3rd of may, 2007. And #3/5/2007# will always
represent the 5th of march, 2007. Two different dates, two different
doubles. Try it in both computers and you'll see.

Regards,

Branco.
 
Back
Top