Results 1 to 6 of 6

Thread: How to change a date to a double

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    105

    How to change a date to a double

    Does anyone know how to change a date into a double?

    I've used the DateTime.ToOADate and i can get the NOW and TODAY dates to convert to a double but i can't work out how to get a specific date,

    EG:

    1/6/2003 (thats 1st June, for those that use the US notion not 6th Jan)

    Can anyone help?

  2. #2
    Junior Member
    Join Date
    Jan 2003
    Posts
    17

    Post I See...

    Try to use this:

    Code:
        Dim d As Double
        Dim x As Integer
        x = InputBox("Enter", "Title", 12)
        d = CDbl(x)
    Last edited by Excelsoft; Jun 8th, 2003 at 06:27 AM.
    Excelsoft IT

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    hmmmm........, That looks like VB6 to me and wont work in .NET

    After mucking around with it, changing the Integer to a Date.
    It errors out with a "Converstion from Date to Double requires calling the Date.ToOADate method" which was what it was doing before. Like i said in the above post NOW and TODAY work ok but not a specific date.

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VB Code:
    1. Dim c As Date
    2.          c = Convert.ToDateTime("01/06/03")
    3.         Dim r As Integer
    4.         MsgBox(c.ToString)
    5.         r = c.ToOADate
    6.         MsgBox(r.ToString)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    That looks like it'll work nemaroller, i'll test it out and see.

    Thanks

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    Yup! Worked, excellent.

    Thank you very much nemaroller

Posting Permissions

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



Click Here to Expand Forum to Full Width