convert excel date to asp date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lyne_asp
    New Member
    • Aug 2006
    • 20

    convert excel date to asp date

    Please help me to convert excel date to asp date.

    Here is my code


    objConnEx.open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=D:\Netro ot\WebApp\testp rograms\Shuttle _Service\Attach ment\BusRequest .xls;Extended Properties=Exce l 8.0;HDR=Yes;IME X=1;"
    set objRS = server.createOb ject("ADODB.rec ordset")
    SQL = "SELECT * from [BusRequest$]"
    objRS.Open SQL,objConnEx, 1

    Do until objRS.eof

    Response.write( objRS.fields(0) .Value)
    // The value of this in excel is 06/29/2007


    objRS.Movenext
    Loop

    The output of this script is
    39336
    How Can I convert 39336 to 6/29/2007?

    Thanks


    THanks
  • justintaitt
    New Member
    • Jun 2007
    • 11

    #2
    Hi,
    You could probably try the FromOADate() function. The only thing was when I tried it with the value you supplied I was off by 74 days so I subtracted that. Not sure if it would be affected by leap years though.


    Code:
     
            Dim myDate As DateTime
    
    myDate = DateTime.FromOADate(39336 - 74)
    
    Response.Write(myDate.ToString)
    The 39336 would be replaced with a variable. Hope this helps.

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      Originally posted by justintaitt
      Hi,
      You could probably try the FromOADate() function. The only thing was when I tried it with the value you supplied I was off by 74 days so I subtracted that. Not sure if it would be affected by leap years though.
      I tried it in excel and I also got 9/11/07

      Jared

      Comment

      • justintaitt
        New Member
        • Jun 2007
        • 11

        #4
        Originally posted by jhardman
        I tried it in excel and I also got 9/11/07

        Jared
        I don't know then, I created a new website and tried that and it worked.

        Forgive me for asking, but did you subtract the 74?

        Comment

        Working...