+ Reply to Thread
Results 1 to 8 of 8

CDate Problem

  1. #1
    Registered User
    Join Date
    07-21-2005
    Posts
    4

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

  2. #2
    Jim May
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  3. #3
    Harald Staff
    Guest

    Re: CDate Problem

    Try Datevalue instead of CDate.

    HTH. Best wishes Harald

    "sil0000" <[email protected]> skrev i
    melding news:[email protected]...
    >
    > 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
    >




  4. #4
    Registered User
    Join Date
    07-21-2005
    Posts
    4
    I've tried with DataValue and also with DataSerial, both work rigth in Excel 2003 but not correctly in XP

  5. #5
    Registered User
    Join Date
    07-21-2005
    Posts
    4
    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??

  6. #6
    Harald Staff
    Guest

    Re: 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" <[email protected]> skrev i
    melding news:[email protected]...
    >
    > 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
    >




  7. #7
    Jim May
    Guest

    Re: CDate Problem

    yes Ver 11.?? is Office 2003.

    "sil0000" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  8. #8
    Registered User
    Join Date
    07-21-2005
    Posts
    4
    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!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1