CDate Problem

  • Thread starter Thread starter sil0000
  • Start date Start date
S

sil0000

Hello!
I have a problem converting string to date.

Working with Excel 2003, function Cdate works fine. If I do

..Range(myCell).Value = CDate("22/02/2005")

in the cell is shown 22/02/2005 (My regional configuration is
dd/mm/yyyy).

But if I use this program with Excel XP, the function doesn't work
correctly because it tries to make a date which is the day 2 of the
month 22.
I've tried to do MiDate = CDate(#2/22/2005#) but it doesn't work.

The solution in office XP is:
..Range(myCell).NumberFormat = "dd/mm/yyyy"
..Range(myCell).Value = "22/02/2005"

But this solution doesn't work in Excel 2003!!!

The problem is that I need a solution working for both versions. Is it
possible to know the version of Excel?

Can anyone help me please???

Thank-you!!!
 
This example displays a message box that contains the Microsoft Excel
version number and the name of the operating system.

MsgBox "Welcome to Microsoft Excel version " & _
Application.Version & " running on " & _
Application.OperatingSystem & "!"
 
I've tried with DataValue and also with DataSerial, both work rigth in
Excel 2003 but not correctly in XP
 
Jim,
I don't know why but the information in Application.Version an
Application.OperatingSystem doesn't match with my computer. I'm workin
with windows XP and Office 2003, but I have
Application.Version = 11.0
Application.OperatingSystem = Windows (32-bit) NT 5.01

In the computer with Windows and Office XP I have
Application.Version = 10.0
Application.OperatingSystem = Windows (32-bit) NT 5.01

The version 11.0 always means Excel 2003?
 
I have multiple versions on this computer and it is set to dd mm yyyy date
format.
Datevalue("22/02/2005")
works perfect on Excel 2003 and Excel XP. Your problem is elsewhere. There
is btw a difference between Data and Date

HTH. Best wishes Harald
 
Hi Jim and Harald!

I was wrong in the other message, DateSerial and DateValue were the
functions that didn't work

Finally I've chosen the option of get the Version and pass the value in
a different way depending on the version, it's not the solution I like
best but it's the only one that works..

Thank-you for your help!!
 
Back
Top