ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CDate Problem (https://www.excelbanter.com/excel-programming/335155-cdate-problem.html)

sil0000

CDate Problem
 

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!!!


--
sil0000
------------------------------------------------------------------------
sil0000's Profile: http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020


Jim May

CDate Problem
 
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 & "!"
"sil0000" wrote in
message ...

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!!!


--
sil0000
------------------------------------------------------------------------
sil0000's Profile:
http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020




Harald Staff

CDate Problem
 
Try Datevalue instead of CDate.

HTH. Best wishes Harald

"sil0000" skrev i
melding ...

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!!!


--
sil0000
------------------------------------------------------------------------
sil0000's Profile:

http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020




sil0000[_2_]

CDate Problem
 

I've tried with DataValue and also with DataSerial, both work rigth in
Excel 2003 but not correctly in XP


--
sil0000
------------------------------------------------------------------------
sil0000's Profile: http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020


sil0000[_3_]

CDate Problem
 

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?

--
sil000
-----------------------------------------------------------------------
sil0000's Profile: http://www.excelforum.com/member.php...fo&userid=2546
View this thread: http://www.excelforum.com/showthread.php?threadid=38902


Harald Staff

CDate Problem
 
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

"sil0000" skrev i
melding ...

I've tried with DataValue and also with DataSerial, both work rigth in
Excel 2003 but not correctly in XP


--
sil0000
------------------------------------------------------------------------
sil0000's Profile:

http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020




Jim May

CDate Problem
 
yes Ver 11.?? is Office 2003.

"sil0000" wrote in
message ...

Jim,
I don't know why but the information in Application.Version and
Application.OperatingSystem doesn't match with my computer. I'm working
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??


--
sil0000
------------------------------------------------------------------------
sil0000's Profile:
http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020




sil0000[_4_]

CDate Problem
 

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!!


--
sil0000
------------------------------------------------------------------------
sil0000's Profile: http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020



All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com